Fix for 45027
[apps/osp/Gallery.git] / src / GlAlbumListPresentationModel.cpp
index ebcca82..9100044 100644 (file)
@@ -68,7 +68,7 @@ static const int GAP = 10;
 static const int HEIGHT_OFFSET = 5;
 static const int Y_POS_CANVAS = 260;
 static const int FOLDER_NAME_WIDTH = 165;
-static const int FOLDER_NAME_HEIGHT = 38 ;
+static const int FOLDER_NAME_HEIGHT = 38;
 
 
 static const int ALPHA_BG = 110;
@@ -110,6 +110,8 @@ AlbumListPresentationModel::~AlbumListPresentationModel(void)
 {
        AppLogDebug("ENTER");
        DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
+       delete __pFolderBackgroundBitmap;
+       delete __pContentManager;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -321,16 +323,19 @@ AlbumListPresentationModel::RenameAlbum(const String& orgPath, const String& new
        return r;
 }
 
-void AlbumListPresentationModel::OnContentScanCompleted (const Tizen::Base::String &scanPath)\r
+bool AlbumListPresentationModel::OnContentScanCompleted (const Tizen::Base::String &scanPath)\r
 {
        AppLogDebug("ENTER");\r
-       if (__pAlbumListener && ( scanPath == __renameNewPath))\r
+       if (__pAlbumListener && (scanPath == __renameNewPath))\r
        {
                InitializeAlbumInfoList(CONTENT_TYPE_ALL);
                __pAlbumListener->OnAlbumRenameComplete();
                __renameNewPath = L"";
+               AppLogDebug("EXIT");
+               return true;
        }
        AppLogDebug("EXIT");
+       return false;
 }
 
 void
@@ -440,12 +445,14 @@ AlbumListPresentationModel::DrawFontImage(Canvas& canvas, AlbumInfo* pAlbumInfo,
        enTextCount.SetTextAbbreviationEnabled(true);
        enTextCount.Add(textElementCount);
 
-       pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP + FOLDER_NAME_WIDTH , rectCanvas.y + HEIGHT_OFFSET);
+       pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP + FOLDER_NAME_WIDTH,
+                       rectCanvas.y + HEIGHT_OFFSET);
        canvas.SetFont(ftCnt);
        canvas.SetForegroundColor(Color::GetColor(COLOR_ID_WHITE));
        canvas.DrawText(pointText, enTextCount);
 
-       pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP , rectCanvas.y + GAP + HEIGHT_OFFSET);
+       pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP,
+                       rectCanvas.y + GAP + HEIGHT_OFFSET);
        canvas.SetForegroundColor(Color::GetColor(COLOR_ID_WHITE));
        canvas.DrawText(pointText, enText);
 
@@ -534,7 +541,7 @@ AlbumListPresentationModel::GetDirectoryName(String& directoryPath) const
 {
        AppLogDebug("ENTER");
        String directoryName;
-       int lastIndex = -1 ;
+       int lastIndex = -1;
 
        directoryPath.LastIndexOf(DIRECTORY_SEPARATOR, directoryPath.GetLength() - 1, lastIndex);
        directoryPath.SubString(lastIndex + 1, directoryName);
@@ -674,6 +681,8 @@ AlbumListPresentationModel::InitializeAlbumInfoList(const ContentType& contentTy
 
                                        pAllAlbumInfo->AppendDirectory(*pDirPath);
                                        pAllAlbumInfo->AppendContentIdList(*pContentIdList);
+
+                                       pContentIdList->RemoveAll(true);
                                        delete pContentIdList;
                                }
                        }
@@ -688,6 +697,8 @@ AlbumListPresentationModel::InitializeAlbumInfoList(const ContentType& contentTy
 
                                        pAllAlbumInfo->AppendDirectory(*pDirPath);
                                        pAllAlbumInfo->AppendContentIdList(*pContentIdList);
+
+                                       pContentIdList->RemoveAll(true);
                                        delete pContentIdList;
                                }
                        }
@@ -709,13 +720,21 @@ AlbumListPresentationModel::InitializeAlbumInfoList(const ContentType& contentTy
 
                                                pAllAlbumInfo->AppendDirectory(*pDirPath);
                                                pAllAlbumInfo->AppendContentIdList(*pContentIdList);
+
+                                               pSubDirList->RemoveAll(true);
                                                delete pSubDirList;
                                        }
-                                       delete pContentIdList;
+
+                                       if (pContentIdList != NULL)
+                                       {
+                                               pContentIdList->RemoveAll(true);
+                                               delete pContentIdList;
+                                       }
                                }
                                if (pAlbumInfo != null && pAlbumInfo->GetContentIdCount() > 0)
                                {
                                        __pAlbumInfoList->Add(pAlbumInfo);
+                                       AppLog("Adding album");
                                }
                                else
                                {
@@ -774,13 +793,19 @@ AlbumListPresentationModel::InitializeAlbumInfoList(const ContentType& contentTy
 
        if (pContentDirectoryPathList != null)
        {
+               pContentDirectoryPathList->RemoveAll(true);
                delete pContentDirectoryPathList;
        }
+       ClearThumbnailRequests(false);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
        return;
 
 CATCH:
+if (pContentDirectoryPathList != null)
+{
+       pContentDirectoryPathList->RemoveAll(true);
        delete pContentDirectoryPathList;
+}
        delete pAllAlbumInfo;
        delete pCameraAlbumInfo;
        delete pDownloadAlbumInfo;
@@ -863,7 +888,13 @@ AlbumListPresentationModel::GetContentIdListInDirectoryN(const String& directory
                }
                delete pEnum;
        }
-       delete pContentInfoList;
+
+       if (pContentInfoList != NULL)
+       {
+               pContentInfoList->RemoveAll(true);
+               delete pContentInfoList;
+       }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return pContentIdList;
@@ -1028,6 +1059,8 @@ AlbumListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
                        }
                }
 
+               delete pThumbnailInfo;
+
                if (__pPresentationModelListener->GetCount() > 0)
                {
                        IEnumerator* pEnum = __pPresentationModelListener->GetEnumeratorN();