Fixed memory leaks
[apps/osp/Gallery.git] / src / GlFileListEditorForm.cpp
index 114a25f..a50116b 100644 (file)
@@ -58,7 +58,7 @@ static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Val
 static const String RESERVED_MEDIA_PATH = Environment::GetMediaPath();
 
 FileListEditorForm::FileListEditorForm(void)
-       : __pContextMenuShare(null)
+       : __pShareContextMenu(null)
        , __pOptionMenu(null)
        , __pDeletePopup(null)
        , __morePosition(Point(0, 0))
@@ -79,7 +79,15 @@ FileListEditorForm::~FileListEditorForm(void)
        AppLogDebug("ENTER");
        if (__pContentDirectoryList != null)
        {
+               __pContentDirectoryList->RemoveAll(true);
                delete __pContentDirectoryList;
+               __pContentDirectoryList = null;
+       }
+
+       if (__pPopUp != null)
+       {
+               delete __pPopUp;
+               __pPopUp = null;
        }
 
        if (__pContentDirectoryNameList != null)
@@ -168,10 +176,14 @@ FileListEditorForm::InitializeFooter(void)
                        footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
                        pFooter->AddItem(footerConfirm);
                        pFooter->SetItemEnabled(0, false);
+                       pFooter->SetShowState(true);
+                       pFooter->Invalidate(true);
                }
                else
                {
                        pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
+                       pFooter->SetShowState(false);
+                       pFooter->Invalidate(true);
                }
 
                SetFormBackEventListener(this);
@@ -314,11 +326,11 @@ FileListEditorForm::OnTerminating(void)
                __pOptionMenu = null;
        }
 
-       if (__pContextMenuShare != null)
+       if (__pShareContextMenu != null)
        {
-               __pContextMenuShare->RemoveActionEventListener(*this);
-               delete __pContextMenuShare;
-               __pContextMenuShare = null;
+               __pShareContextMenu->RemoveActionEventListener(*this);
+               delete __pShareContextMenu;
+               __pShareContextMenu = null;
        }
 
        if (__pDeletePopup != null)
@@ -347,34 +359,33 @@ FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
 
        case IDA_FOOTER_SHARE:
        {
-               if ( __pContextMenuShare != NULL)
+               if ( __pShareContextMenu != NULL)
                {
-                       delete __pContextMenuShare;
-                       __pContextMenuShare = null;
+                       delete __pShareContextMenu;
+                       __pShareContextMenu = null;
                }
 
-               __pContextMenuShare = new (std::nothrow) ContextMenu();
-               __pContextMenuShare->Construct(Point(GetClientAreaBounds().width/3 + 15, GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST , CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
-               __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
+               __pShareContextMenu = new (std::nothrow) ContextMenu();
+               __pShareContextMenu->Construct(Point(GetClientAreaBounds().width/3 + 15, GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST , CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
+               __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
                                IDA_CONTEXT_MENU_SHARE_MESSAGE);
-               __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
+               __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
                                IDA_CONTEXT_MENU_SHARE_EMAIL);
-               __pContextMenuShare->AddActionEventListener(*this);
-
-
+               __pShareContextMenu->SetFocusable(true);
+               __pShareContextMenu->AddActionEventListener(*this);
 
                        Rectangle rect = source.GetBounds();
                        if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
                        {
-                               __pContextMenuShare->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y));
+                               __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y));
                        }
                        else
                        {
-                               __pContextMenuShare->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y - H_TOAST_LABEL));
+                               __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y - H_TOAST_LABEL));
                        }
 
-                       __pContextMenuShare->SetShowState(true);
-                       __pContextMenuShare->Show();
+                       __pShareContextMenu->SetShowState(true);
+                       __pShareContextMenu->Show();
 
        }
        break;
@@ -863,6 +874,7 @@ FileListEditorForm::SetUpPopup(void)
 
        __pDeletePopup = new (std::nothrow) Popup();
        __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
+       __pDeletePopup->SetPropagatedKeyEventListener(this);
 
        Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
 
@@ -923,6 +935,7 @@ FileListEditorForm::RefreshFolderList(void)
 
        if (__pContentDirectoryList != null)
        {
+               __pContentDirectoryList->RemoveAll(true);
                delete __pContentDirectoryList;
        }
        __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
@@ -1006,18 +1019,27 @@ FileListEditorForm::OnFormBackRequested(Form& source)
                }
                else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
                {
-                       AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
-                               (pSceneManager->GetCurrentScene()->GetPanel());
-                       if (pSelectionPanel != null)
+                       if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true )
+                       {
+                               __pShareContextMenu->SetShowState(false);
+                       }
+                       else
                        {
-                               IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
-                               if (pList == null)
+                               AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
+                               (pSceneManager->GetCurrentScene()->GetPanel());
+                               if (pSelectionPanel != null)
                                {
-                                       pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
-                               }
+                                       IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
+                                       if (pList == null)
+                                       {
+                                               pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+                                       }
+
+                                       pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
+                                                       SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pList);
 
-                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
-                                                  SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pList);
+
+                               }
                        }
                }
                else
@@ -1105,6 +1127,19 @@ FileListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen
        }
 }
 
+bool
+FileListEditorForm::OnKeyReleased(Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
+{
+       AppLogDebug("ENTER");
+
+       if(keyEventInfo.GetKeyCode() == KEY_BACK)
+       {
+               _overlayMsg = false;
+               __pDeletePopup->SetShowState(false);
+               __pDeletePopup->Invalidate(true);
+       }
+       return true;
+}
 
 result
 FileListEditorForm::MoveToAlbum(const String& destDirectory)
@@ -1249,9 +1284,9 @@ FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
                }
        }
 
-       if (__pContextMenuShare != null && __pContextMenuShare->GetShowState() == true )
+       if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true )
        {
-               __pContextMenuShare->SetShowState(false);
+               __pShareContextMenu->SetShowState(false);
        }
 
        if ( checkedCount > 0)