Apply error checking macro to Create functions 97/36897/1 submit/tizen_tv/20150317.010306
authorKim Tae Soo <taesoo46.kim@samsung.com>
Tue, 17 Mar 2015 01:01:01 +0000 (10:01 +0900)
committerKim Tae Soo <taesoo46.kim@samsung.com>
Tue, 17 Mar 2015 01:01:01 +0000 (10:01 +0900)
Change-Id: I8e8edc4a9d034f06ce9c260359d93f8edd30197e
Signed-off-by: Kim Tae Soo <taesoo46.kim@samsung.com>
include/category-layout.h
src/views/album-layout.cpp
src/views/album-songs-layout.cpp
src/views/category-layout.cpp
src/views/category-songs-layout.cpp
src/views/folder-layout.cpp
src/views/song-layout.cpp

index 848eee2..9697f90 100644 (file)
@@ -114,6 +114,8 @@ private:
        void m_EmptyLayout(bool sort_flag);
        void m_ShowCategorySongs(void);
 
+       const char *m_CategorySongLayoutId(void);
+
 protected:
        bool t_SetEdje(const char *layout);
        void t_UpdateLayout(bool sort_flag);
index d07aa4b..a56e0a6 100644 (file)
@@ -411,15 +411,17 @@ void CAlbumLayout::m_UpdateAlbumGrid(bool sort_flag)
 bool CAlbumLayout::Create(CLayoutMgr *mgr, const char *albumId)
 {
        ASSERT(!m);
+       ASSERT(mgr);
 
-       Evas_Object *base = NULL;
-       Evas_Object *win = NULL;
-       Evas_Object *layout = NULL;
-       CMusicController *mhandle = NULL;
-       CViewMgr *vmgr = NULL;
-       SParcel parcel;
+       _CREATE_BEGIN{
+               Evas_Object *base = NULL;
+               Evas_Object *win = NULL;
+               Evas_Object *layout = NULL;
+               CMusicController *mhandle = NULL;
+               CViewMgr *vmgr = NULL;
+               CAlbumSongsLayout *layoutAlbumSongs = NULL;
+               SParcel parcel;
 
-       _CREATE_BEGIN {
                _CHECK(m = new SAlbumLayout)
                _CHECK(vmgr = CViewMgr::GetInstance())
                _CHECK(base = mgr->Base())
@@ -427,11 +429,11 @@ bool CAlbumLayout::Create(CLayoutMgr *mgr, const char *albumId)
                _CHECK(mhandle = CMusicController::GetInstance())
                _CHECK(layout = CCommonUI::AddBase(base, MUSIC_ALBUM_LAYOUT))
                _CHECK(CExtBaseLayout::Create(layout))
-               _CHECK(m->layoutAlbumSongs = new CAlbumSongsLayout(MUSIC_ALBUM_SONGS_LAYOUT))
-               _CHECK(m->layoutAlbumSongs->Create(mgr))
-               _CHECK(mgr->AddLayout(m->layoutAlbumSongs))
+               _CHECK(layoutAlbumSongs = new CAlbumSongsLayout(MUSIC_ALBUM_SONGS_LAYOUT))
+               _CHECK(layoutAlbumSongs->Create(mgr))
+               _CHECK(mgr->AddLayout(layoutAlbumSongs))
 
-               _WHEN_SUCCESS {
+               _WHEN_SUCCESS{
                        if (albumId) {
                                m->album_id = new char[strlen(albumId) + 1];
                                strcpy(m->album_id, albumId);
@@ -446,6 +448,7 @@ bool CAlbumLayout::Create(CLayoutMgr *mgr, const char *albumId)
                        m->lmgr = mgr;
                        m->callback.cbHandleEmptyStatus = NULL;
                        m->callback.cookie = NULL;
+                       m->layoutAlbumSongs = layoutAlbumSongs;
 
                        m_CreateAlbumGrid();
                        Connect(layout, ALBUM_LAYOUT, TYPE_KEY_DOWN);
@@ -457,7 +460,7 @@ bool CAlbumLayout::Create(CLayoutMgr *mgr, const char *albumId)
                        m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel);
                }
 
-               _CHECK_FAIL{}
+               _CHECK_FAIL{ mgr->RemoveLayout(layoutAlbumSongs); }
                _CHECK_FAIL{ m->layoutAlbumSongs->Destroy(); }
                _CHECK_FAIL{ delete m->layoutAlbumSongs; }
                _CHECK_FAIL{ CExtBaseLayout::Destroy(); }
@@ -476,6 +479,8 @@ void CAlbumLayout::Destroy(void)
 {
        ASSERT(m);
 
+       Disconnect(Layout());
+
        m->lmgr->RemoveLayout(m->layoutAlbumSongs);
        m->layoutAlbumSongs->Destroy();
        delete m->layoutAlbumSongs;
index 685137c..6d43fed 100644 (file)
@@ -476,79 +476,44 @@ void CAlbumSongsLayout::m_CreateSongList(void)
 bool CAlbumSongsLayout::Create(CLayoutMgr *mgr)
 {
        ASSERT(!m);
+       ASSERT(mgr);
+
+       _CREATE_BEGIN{
+               Evas_Object *base = NULL;
+               Evas_Object *win = NULL;
+               Evas_Object *layout = NULL;
+               CMusicController *mhandle = NULL;
+               CViewMgr *vmgr = NULL;
+               CAlbumInfo *alinfo = NULL;
+
+               _CHECK(m = new SAlbumSongsLayout)
+               _CHECK(vmgr = CViewMgr::GetInstance())
+               _CHECK(base = mgr->Base())
+               _CHECK(win = vmgr->Window())
+               _CHECK(mhandle = CMusicController::GetInstance())
+               _CHECK(layout = CCommonUI::AddBase(base, MUSIC_ALBUM_SONGS_LAYOUT))
+               _CHECK(CExtBaseLayout::Create(layout))
+               _CHECK(alinfo = new CAlbumInfo)
+
+               _WHEN_SUCCESS{
+                       m->win = win;
+                       m->base = base;
+                       m->vmgr = vmgr;
+                       m->mhandle = mhandle;
+                       m->mgr = mgr;
+                       m->alinfo = alinfo;
+                       Connect(layout, ALBUM_SONGS_LAYOUT, TYPE_KEY_DOWN);
+               }
 
-       Evas_Object *base = NULL;
-       Evas_Object *win = NULL;
-       Evas_Object *layout = NULL;
-       CMusicController *mhandle;
-       CViewMgr *vmgr;
-
-       if (!mgr)
-               return false;
-
-       m = new SAlbumSongsLayout;
-       if (!m) {
-               _ERR(" calloc failed ");
-               return false;
-       }
-
-       vmgr = CViewMgr::GetInstance();
-       if (!vmgr) {
-               _ERR(" get view mgr failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       base = mgr->Base();
-       if (!base) {
-               _ERR(" get base failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       win = vmgr->Window();
-       if (!win) {
-               _ERR(" vimewmgr get win failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       mhandle = CMusicController::GetInstance();
-       if (!mhandle) {
-               _ERR(" music controller get music instance failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       layout = CCommonUI::AddBase(base, MUSIC_ALBUM_SONGS_LAYOUT);
-       if (!layout) {
-               _ERR(" get layout failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       bool r = CExtBaseLayout::Create(layout);
-       if (!r) {
-               _ERR(" CBaseLayout creation failed ");
-               evas_object_del(layout);
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       m->win = win;
-       m->base = base;
-       m->vmgr = vmgr;
-       m->mhandle = mhandle;
-       m->mgr = mgr;
-       m->alinfo = new CAlbumInfo;
-
-       Connect(layout, ALBUM_SONGS_LAYOUT, TYPE_KEY_DOWN);
+               _CHECK_FAIL{ delete alinfo; }
+               _CHECK_FAIL{ CExtBaseLayout::Destroy(); }
+               _CHECK_FAIL{ evas_object_del(layout); }
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{ delete m; m = NULL; }
+       } _CREATE_END_AND_CATCH{ return false; }
  
        return true;
 }
@@ -557,6 +522,8 @@ void CAlbumSongsLayout::Destroy(void)
 {
        ASSERT(m);
 
+       Disconnect(Layout());
+
        if (m->alinfo->FlagCreate())
                m->alinfo->Destroy();
        delete m->alinfo;
index ec2a074..f32efec 100644 (file)
@@ -986,6 +986,20 @@ void CCategoryLayout::m_ShowCategorySongs(void)
 }
 
 
+const char *CCategoryLayout::m_CategorySongLayoutId(void)
+{
+       const char *layoutId;
+
+       if (!strcmp(LayoutId(), MUSIC_CATEGORY_ARTIST_LAYOUT))
+               layoutId = MUSIC_CATEGORY_ARTIST_SONGS_LAYOUT;
+       else if (!strcmp(LayoutId(), MUSIC_CATEGORY_GENRE_LAYOUT))
+               layoutId = MUSIC_CATEGORY_GENRE_SONGS_LAYOUT;
+       else if (!strcmp(LayoutId(), MUSIC_CATEGORY_PLAYLISTS_LAYOUT))
+               layoutId = MUSIC_CATEGORY_PLAYLISTS_SONGS_LAYOUT;
+
+       return layoutId;
+}
+
 
 bool CCategoryLayout::t_SetEdje(const char *szLayout)
 {
@@ -1083,127 +1097,64 @@ void CCategoryLayout::t_UpdateLayoutWithFocus(void)
 bool CCategoryLayout::Create(CLayoutMgr *mgr)
 {
        ASSERT(!m);
+       ASSERT(mgr);
+
+       _CREATE_BEGIN{
+               Evas_Object *base = NULL;
+               Evas_Object *win = NULL;
+               Evas_Object *layout = NULL;
+               CMusicController *pMusicController = NULL;
+               CViewMgr *vmgr = NULL;
+               CEntryPopup *popup = NULL;
+               CCategorySongsLayout *layoutCatSongs = NULL;
+               const char *catSongLayoutId = NULL;
+
+               _CHECK(m = new SCategoryLayout)
+               _CHECK(vmgr = CViewMgr::GetInstance())
+               _CHECK(base = mgr->Base())
+               _CHECK(win = vmgr->Window())
+               _CHECK(pMusicController = CMusicController::GetInstance())
+               _CHECK(layout = elm_layout_add(base))
+               _CHECK(CExtBaseLayout::Create(layout))
+               _CHECK(popup = new CEntryPopup)
+               _CHECK(catSongLayoutId = m_CategorySongLayoutId())
+               _CHECK(layoutCatSongs = new CCategorySongsLayout(catSongLayoutId))
+               _CHECK(layoutCatSongs->Create(mgr, this))
+               _CHECK(mgr->AddLayout(layoutCatSongs))
+
+               _WHEN_SUCCESS{
+                       memset(&t, 0, sizeof(SCategoryLayoutProtected));
+
+                       m->win = win;
+                       t.base = base;
+                       m->vmgr = vmgr;
+                       m->pMusicController = pMusicController;
+                       m->lmgr = mgr;
+                       t.depth = E_DEPTH_CATEGORY;
+                       m->callback.cbHandleEmptyStatus = NULL;
+                       m->callback.cookie = NULL;
+                       t.epopup = popup;
+                       m->catSongLayoutId = catSongLayoutId;
+                       m->layoutCatSongs = layoutCatSongs;
+
+                       t_UpdateLayout(false);
+
+                       Connect(Layout(), CATEGORY_LAYOUT, TYPE_KEY_DOWN);
+               }
 
-       Evas_Object *base = NULL;
-       Evas_Object *win = NULL;
-       Evas_Object *layout = NULL;
-       CMusicController *pMusicController = NULL;
-       CViewMgr *vmgr = NULL;
-
-       if (!mgr)
-               return false;
-
-       m = new SCategoryLayout;
-       if (!m) {
-               _ERR(" calloc failed ");
-               return false;
-       }
-
-       memset(&t, 0, sizeof(SCategoryLayoutProtected));
-
-       vmgr = CViewMgr::GetInstance();
-       if (!vmgr) {
-               _ERR(" get view mgr failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       base = mgr->Base();
-       if (!base) {
-               _ERR(" get base failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       win = vmgr->Window();
-       if (!win) {
-               _ERR(" vimewmgr get win failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       pMusicController = CMusicController::GetInstance();
-       if (!pMusicController) {
-               _ERR(" music controller get music instance failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       layout = elm_layout_add(base);
-       if (!layout) {
-               _ERR(" layout creation failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       bool r = CExtBaseLayout::Create(layout);
-       if (!r) {
-               _ERR(" CBaseLayout creation failed ");
-               evas_object_del(layout);
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       t.epopup = new CEntryPopup;
-       if (!t.epopup) {
-               _ERR(" CEntryPopup creation failed ");
-               CExtBaseLayout::Destroy();
-               evas_object_del(layout);
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       if (!strcmp(LayoutId(), MUSIC_CATEGORY_ARTIST_LAYOUT))
-               m->catSongLayoutId = MUSIC_CATEGORY_ARTIST_SONGS_LAYOUT;
-       else if (!strcmp(LayoutId(), MUSIC_CATEGORY_GENRE_LAYOUT))
-               m->catSongLayoutId = MUSIC_CATEGORY_GENRE_SONGS_LAYOUT;
-       else if (!strcmp(LayoutId(), MUSIC_CATEGORY_PLAYLISTS_LAYOUT))
-               m->catSongLayoutId = MUSIC_CATEGORY_PLAYLISTS_SONGS_LAYOUT;
-
-       m->layoutCatSongs = new CCategorySongsLayout((const char *)m->catSongLayoutId);
-       if (!m->layoutCatSongs) {
-               _ERR(" Memory alloc failed ");
-               delete t.epopup;
-               CExtBaseLayout::Destroy();
-               evas_object_del(layout);
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       r = m->layoutCatSongs->Create(mgr, this);
-       if (!r) {
-               _ERR(" CCategorySongsLayout creation failed ");
-               delete m->layoutCatSongs;
-               delete t.epopup;
-               CExtBaseLayout::Destroy();
-               evas_object_del(layout);
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       mgr->AddLayout(m->layoutCatSongs);
-
-       m->win = win;
-       t.base = base;
-       m->vmgr = vmgr;
-       m->pMusicController = pMusicController;
-       m->lmgr = mgr;
-       t.depth = E_DEPTH_CATEGORY;
-       m->callback.cbHandleEmptyStatus = NULL;
-       m->callback.cookie = NULL;
-
-       t_UpdateLayout(false);
-
-       Connect(Layout(), CATEGORY_LAYOUT, TYPE_KEY_DOWN);
+               _CHECK_FAIL{ mgr->RemoveLayout(layoutCatSongs); }
+               _CHECK_FAIL{ m->layoutCatSongs->Destroy(); }
+               _CHECK_FAIL{ delete layoutCatSongs; }
+               _CHECK_FAIL{}
+               _CHECK_FAIL{ delete popup; }
+               _CHECK_FAIL{ CExtBaseLayout::Destroy(); }
+               _CHECK_FAIL{ evas_object_del(layout); }
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{ delete m; m = NULL; }
+       } _CREATE_END_AND_CATCH{ return false; }
 
        return true;
 }
@@ -1215,6 +1166,7 @@ void CCategoryLayout::Destroy(void)
 
        Disconnect(Layout());
 
+       m->lmgr->RemoveLayout(m->layoutCatSongs);
        m->layoutCatSongs->Destroy();
        delete m->layoutCatSongs;
 
index 4da5a47..986c0fd 100644 (file)
@@ -844,79 +844,42 @@ bool CCategorySongsLayout::m_SetEdje(const char *szLayout)
 bool CCategorySongsLayout::Create(CLayoutMgr *mgr, CCategoryLayout *parent)
 {
        ASSERT(!m);
+       ASSERT(mgr);
+
+       _CREATE_BEGIN{
+               Evas_Object *base = NULL;
+               Evas_Object *win = NULL;
+               Evas_Object *layout = NULL;
+               CMusicController *mhandle = NULL;
+               CViewMgr *vmgr = NULL;
+
+               _CHECK(m = new SCategorySongsLayout)
+               _CHECK(vmgr = CViewMgr::GetInstance())
+               _CHECK(base = mgr->Base())
+               _CHECK(win = vmgr->Window())
+               _CHECK(mhandle = CMusicController::GetInstance())
+               _CHECK(layout = CCommonUI::AddBase(base, MUSIC_CATEGORY_SONGS_LAYOUT))
+               _CHECK(CExtBaseLayout::Create(layout))
+
+               _WHEN_SUCCESS{
+                       m->win = win;
+                       m->base = base;
+                       m->vmgr = vmgr;
+                       m->mhandle = mhandle;
+                       m->mgr = mgr;
+                       m->parent = parent;
+
+                       Connect(layout, CATEGORY_SONGS_LAYOUT, TYPE_KEY_DOWN);
+               }
 
-       Evas_Object *base = NULL;
-       Evas_Object *win = NULL;
-       Evas_Object *layout = NULL;
-       CMusicController *mhandle;
-       CViewMgr *vmgr;
-
-       if (!mgr)
-               return false;
-
-       m = new SCategorySongsLayout;
-       if (!m) {
-               _ERR(" calloc failed ");
-               return false;
-       }
-
-       vmgr = CViewMgr::GetInstance();
-       if (!vmgr) {
-               _ERR(" get view mgr failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       base = mgr->Base();
-       if (!base) {
-               _ERR(" get base failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       win = vmgr->Window();
-       if (!win) {
-               _ERR(" vimewmgr get win failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       mhandle = CMusicController::GetInstance();
-       if (!mhandle) {
-               _ERR(" music controller get music instance failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       layout = CCommonUI::AddBase(base, MUSIC_CATEGORY_SONGS_LAYOUT);
-       if (!layout) {
-               _ERR(" get layout failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       bool r = CExtBaseLayout::Create(layout);
-       if (!r) {
-               _ERR(" CBaseLayout creation failed ");
-               evas_object_del(layout);
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       m->win = win;
-       m->base = base;
-       m->vmgr = vmgr;
-       m->mhandle = mhandle;
-       m->mgr = mgr;
-       m->parent = parent;
-
-       Connect(layout, CATEGORY_SONGS_LAYOUT, TYPE_KEY_DOWN);
+               _CHECK_FAIL{ CExtBaseLayout::Destroy(); }
+               _CHECK_FAIL{ evas_object_del(layout); }
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{ delete m; m = NULL; }
+       } _CREATE_END_AND_CATCH{ return false; }
 
        return true;
 }
@@ -925,6 +888,8 @@ void CCategorySongsLayout::Destroy(void)
 {
        ASSERT(m);
 
+       Disconnect(Layout());
+
        m_RemoveFocusIdler();
        m_EmptySongList();
        CExtBaseLayout::Destroy();
index f362152..7061f07 100644 (file)
@@ -717,87 +717,52 @@ void CFolderLayout::m_CreateTopsection(void)
 bool CFolderLayout::Create(CLayoutMgr *mgr)
 {
        ASSERT(!m);
+       ASSERT(mgr);
+
+       _CREATE_BEGIN{
+               Evas_Object *base = NULL;
+               Evas_Object *win = NULL;
+               Evas_Object *layout = NULL;
+               CMusicController *mhandle = NULL;
+               CViewMgr *vmgr = NULL;
+
+               _CHECK(m = new SFolderLayout)
+               _CHECK(vmgr = CViewMgr::GetInstance())
+               _CHECK(base = mgr->Base())
+               _CHECK(win = vmgr->Window())
+               _CHECK(mhandle = CMusicController::GetInstance())
+               _CHECK(layout = CCommonUI::AddBase(base, MUSIC_FOLDER_LAYOUT))
+               _CHECK(CExtBaseLayout::Create(layout))
+
+               _WHEN_SUCCESS{
+                       m->win = win;
+                       m->base = base;
+                       m->vmgr = vmgr;
+                       m->mhandle = mhandle;
+                       m->lmgr = mgr;
+                       m->depth = E_DEPTH_FOLDER;
+
+                       m_CreateTopsection();
+                       m_CreateFolderGrid();
+
+                       Connect(layout, FOLDER_LAYOUT, TYPE_KEY_DOWN);
 
-       Evas_Object *base = NULL;
-       Evas_Object *win = NULL;
-       Evas_Object *layout = NULL;
-       CMusicController *mhandle = NULL;
-       CViewMgr *vmgr = NULL;
-
-       if (!mgr)
-               return false;
-
-       m = new SFolderLayout;
-       if (!m) {
-               _ERR(" calloc failed ");
-               return false;
-       }
-
-       vmgr = CViewMgr::GetInstance();
-       if (!vmgr) {
-               _ERR(" get view mgr failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       base = mgr->Base();
-       if (!base) {
-               _ERR(" get base failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       win = vmgr->Window();
-       if (!win) {
-               _ERR(" vimewmgr get win failed ");
-               delete m;
-               return false;
-       }
-
-       mhandle = CMusicController::GetInstance();
-       if (!mhandle) {
-               _ERR(" music controller get music instance failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       layout = CCommonUI::AddBase(base, MUSIC_FOLDER_LAYOUT);
-       if (!layout) {
-               _ERR(" get layout failed ");
-               delete m;
-               return false;
-       }
-
-       bool r = CExtBaseLayout::Create(layout);
-       if (!r) {
-               _ERR(" CBaseLayout creation failed ");
-               evas_object_del(layout);
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       m->win = win;
-       m->base = base;
-       m->vmgr = vmgr;
-       m->mhandle = mhandle;
-       m->lmgr = mgr;
-       m->depth = E_DEPTH_FOLDER;
-
-       m_CreateTopsection();
-       m_CreateFolderGrid();
-
-       Connect(layout, FOLDER_LAYOUT, TYPE_KEY_DOWN);
+                       SParcel parcel;
+                       parcel.ctxtInfo = NULL;
+                       parcel.updateType = E_LAYOUT_UPDATE;
+                       parcel.layoutId = NULL;
+                       parcel.keyEvent = NULL;
+                       m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel);
+               }
 
-       SParcel parcel;
-       parcel.ctxtInfo = NULL;
-       parcel.updateType = E_LAYOUT_UPDATE;
-       parcel.layoutId = NULL;
-       parcel.keyEvent = NULL;
-       m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel);
+               _CHECK_FAIL{ CExtBaseLayout::Destroy(); }
+               _CHECK_FAIL{ evas_object_del(layout); }
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{ delete m; m = NULL; }
+       } _CREATE_END_AND_CATCH{ return false; }
 
        return true;
 }
@@ -807,6 +772,8 @@ void CFolderLayout::Destroy(void)
 {
        ASSERT(m);
 
+       Disconnect(Layout());
+
        m_RemoveFocusIdler();
        m_EmptyFolderGrid(false);
        CExtBaseLayout::Destroy();
index cad5988..e97e2d9 100644 (file)
@@ -483,100 +483,62 @@ void CSongLayout::m_CreateSongList(void)
 bool CSongLayout::Create(CLayoutMgr *mgr, const char *uri)
 {
        ASSERT(!m);
+       ASSERT(mgr);
+
+       _CREATE_BEGIN{
+               Evas_Object *base = NULL;
+               Evas_Object *win = NULL;
+               Evas_Object *layout = NULL;
+               CMusicController *mhandle = NULL;
+               CViewMgr *vmgr = NULL;
+
+               _CHECK(m = new SSongLayout)
+               _CHECK(vmgr = CViewMgr::GetInstance())
+               _CHECK(base = mgr->Base())
+               _CHECK(win = vmgr->Window())
+               _CHECK(mhandle = CMusicController::GetInstance())
+               _CHECK(layout = CCommonUI::AddBase(base, MUSIC_SONG_LAYOUT))
+               _CHECK(CExtBaseLayout::Create(layout))
+
+               _WHEN_SUCCESS{
+                       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ARTIST_AZ, sm_CbSortArtistAZ);
+                       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ARTIST_ZA, sm_CbSortArtistZA);
+                       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ALBUM_AZ, sm_CbSortAlbumAZ);
+                       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ALBUM_ZA, sm_CbSortAlbumZA);
+
+                       if (uri) {
+                               m->uri = new char[strlen(uri) + 1];
+                               strcpy(m->uri, uri);
+                       }
+                       else
+                               m->uri = NULL;
 
-       Evas_Object *base = NULL;
-       Evas_Object *win = NULL;
-       Evas_Object *layout = NULL;
-       CMusicController *mhandle = NULL;
-       CViewMgr *vmgr = NULL;
-
-       if (!mgr)
-               return false;
-
-       m = new SSongLayout;
-       if (!m) {
-               _ERR(" calloc failed ");
-               return false;
-       }
-
-       vmgr = CViewMgr::GetInstance();
-       if (!vmgr) {
-               _ERR(" get view mgr failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       base = mgr->Base();
-       if (!base) {
-               _ERR(" get base failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       win = vmgr->Window();
-       if (!win) {
-               _ERR(" vimewmgr get win failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       mhandle = CMusicController::GetInstance();
-       if (!mhandle) {
-               _ERR(" music controller get music instance failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       layout = CCommonUI::AddBase(base, MUSIC_SONG_LAYOUT);
-       if (!layout) {
-               _ERR(" get layout failed ");
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       bool r = CExtBaseLayout::Create(layout);
-       if (!r) {
-               _ERR(" CBaseLayout creation failed ");
-               evas_object_del(layout);
-               delete m;
-               m = NULL;
-               return false;
-       }
-
-       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ARTIST_AZ, sm_CbSortArtistAZ);
-       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ARTIST_ZA, sm_CbSortArtistZA);
-       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ALBUM_AZ, sm_CbSortAlbumAZ);
-       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ALBUM_ZA, sm_CbSortAlbumZA);
-
-       if (uri) {
-               m->uri = new char[strlen(uri) + 1];
-               strcpy(m->uri, uri);
-       }
-       else {
-               m->uri = NULL;
-       }
+                       m->win = win;
+                       m->base = base;
+                       m->vmgr = vmgr;
+                       m->mhandle = mhandle;
+                       m->mgr = mgr;
 
-       m->win = win;
-       m->base = base;
-       m->vmgr = vmgr;
-       m->mhandle = mhandle;
-       m->mgr = mgr;
+                       m_CreateSongList();
 
-       m_CreateSongList();
+                       Connect(layout, SONG_LAYOUT, TYPE_KEY_DOWN);
 
-       Connect(layout, SONG_LAYOUT, TYPE_KEY_DOWN);
+                       SParcel parcel;
+                       parcel.ctxtInfo = NULL;
+                       parcel.updateType = E_FOCUS_UPDATE;
+                       parcel.layoutId = MUSIC_SONG_LAYOUT;
+                       parcel.keyEvent = NULL;
+                       m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel);
+               }
 
-       SParcel parcel;
-       parcel.ctxtInfo = NULL;
-       parcel.updateType = E_FOCUS_UPDATE;
-       parcel.layoutId = MUSIC_SONG_LAYOUT;
-       parcel.keyEvent = NULL;
-       m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel);
+               _CHECK_FAIL{ CExtBaseLayout::Destroy(); }
+               _CHECK_FAIL{ evas_object_del(layout); }
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{}
+               _CHECK_FAIL{ delete m; m = NULL; }
+       } _CREATE_END_AND_CATCH{ return false; }
 
        return true;
 }
@@ -585,6 +547,8 @@ void CSongLayout::Destroy(void)
 {
        ASSERT(m);
 
+       Disconnect(Layout());
+
        CExtBaseLayout::Destroy();
        evas_object_del(Layout());