Fixed memory leaks
[apps/osp/Gallery.git] / src / GlFileListForm.cpp
index 0e96fae..52db43c 100644 (file)
@@ -39,7 +39,8 @@ using namespace Tizen::Ui::Scenes;
 using namespace Tizen::Content;
 
 FileListForm::FileListForm(void)
-       : __pOptionMenu(null)
+       : __menuState(true)
+       , __pOptionMenu(null)
        , __pPopUp(null)
        , __pPresentationModel(null)
 {
@@ -50,6 +51,14 @@ FileListForm::FileListForm(void)
 FileListForm::~FileListForm(void)
 {
        AppLogDebug("ENTER");
+
+       if ( __pPopUp != NULL )
+       {
+               delete __pPopUp;
+               __pPopUp = NULL;
+       }
+
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -85,6 +94,8 @@ FileListForm::OnInitializing(void)
 
        InitializeFooter();
        SetFormBackEventListener(this);
+       SetOrientation(ORIENTATION_AUTOMATIC);
+       AddOrientationEventListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -162,7 +173,7 @@ FileListForm::OnActionPerformed(const Control& source, int actionId)
                pDataList->Construct();
                pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_CAMERA_ALLOW_SWITCH), new (std::nothrow) String(APPCONTROL_DATA_TRUE));
                __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CAMERA, APPCONTROL_OPERATION_ID_CREATE_CONTENT,
-                               null, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, null);
+                               null, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, this);
        }
        break;
 
@@ -183,6 +194,24 @@ FileListForm::OnFormBackRequested(Form& source)
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
+void
+FileListForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
+{
+
+
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       pSceneManager->GetCurrentScene();
+
+       if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
+       {
+               AllListPanel* pListPanel = dynamic_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
+               if (pListPanel != null)
+               {
+                       pListPanel->ChangeOrientation();
+               }
+       }
+}
+
 result
 FileListForm::InitializeFooter(void)
 {
@@ -193,8 +222,6 @@ FileListForm::InitializeFooter(void)
 
        pFooter->RemoveAllItems();
        pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
-       pFooter->SetMenuButton();
-       pFooter->SetBackButton();
 
        FooterItem itemCamera;
        itemCamera.Construct(IDA_FOOTER_CAMERA);
@@ -205,6 +232,7 @@ FileListForm::InitializeFooter(void)
        }
        pFooter->AddItem(itemCamera);
 
+       delete pBitmapCamera;
 
        if (__pOptionMenu != null)
        {
@@ -294,24 +322,37 @@ FileListForm::OnSlideSettingPopUpItemSelected(int index)
 }
 
 void
-FileListForm::SetFooterState(bool state)
+FileListForm::SetMenuState(bool state)
 {
-       GetFooter()->SetMenuButtonEnabled(state);
-       GetFooter()->Invalidate(true);
+       __menuState = state;
 }
 
 void
 FileListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
 {
 
-       InitializeFooter();
-
-       if ( __pOptionMenu == null )
+       if (__menuState == true )
        {
-               return ;
+               InitializeFooter();
+
+               if ( __pOptionMenu == null )
+               {
+                       return ;
+               }
+
+               __pOptionMenu->SetShowState(true);
+               __pOptionMenu->Show();
        }
 
-       __pOptionMenu->SetShowState(true);
-       __pOptionMenu->Show();
+}
+
+void
+FileListForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Tizen::Base::String& operationId,
+                       AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
+{
+       AppLogDebug("OnAppControlCompleteResponseReceived : %d", appControlResult);
 
+       GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
+       TryReturnVoid(pGalleryApp != null, "pGalleryApp is null");
+       pGalleryApp->SetFrameEnabled(true);
 }