fix N_SE-56867
authorGwangbok Kim <gwangbok.kim@samsung.com>
Thu, 31 Oct 2013 08:03:22 +0000 (17:03 +0900)
committerGwangbok Kim <gwangbok.kim@samsung.com>
Thu, 31 Oct 2013 08:03:22 +0000 (17:03 +0900)
Change-Id: I40d1ad18374b693da86c22c047321292fde1ed36
Signed-off-by: Gwangbok Kim <gwangbok.kim@samsung.com>
project/inc/DetailViewForm.h
project/src/DetailViewForm.cpp

index 22c1f79..1bfd819 100644 (file)
@@ -52,6 +52,7 @@ private:
        result RemovePerson(void);
        result GetContactsDetail(void);
        result ChangeFavoriteStatus(void);
+       result IsPersonExistProcess(void);
 
 private:
        Tizen::Ui::Controls::Popup* __pPopup;
index cd22ca2..42aedbc 100644 (file)
@@ -215,21 +215,11 @@ DetailViewForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId
        {
                case ID_FOOTER_EDIT:
                {
-                       Person* pPerson = __pAddressbookMgr->GetPersonN(__pPerson->GetId());
-                       if (pPerson == null)
+                       if (!IsPersonExistProcess())
                        {
-                               MessageBox messageBox;
-                               messageBox.Construct(L"Error", "The person doesn't exist.", MSGBOX_STYLE_OK, 0);
-                               int doModal;
-                               messageBox.ShowAndWait(doModal);
-
-                               pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
-
                                break;
                        }
 
-                       delete pPerson;
-
                        ArrayList* pPersonIdList = new (std::nothrow) ArrayList();
                        AppAssert(pPersonIdList);
 
@@ -246,6 +236,11 @@ DetailViewForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId
 
                case ID_FOOTER_DELETE:
                {
+                       if (!IsPersonExistProcess())
+                       {
+                               break;
+                       }
+
                        MessageBox messageBox;
                        int doModal;
                        messageBox.Construct(L"Warning", "Do you really want to delete?", MSGBOX_STYLE_OKCANCEL, 0);
@@ -255,6 +250,7 @@ DetailViewForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId
                        {
                                r = RemovePerson();
                                TryReturnVoid(!IsFailed(r), "Failed to remove the person (%s).", GetErrorMessage(r));
+
                                if (__previousSceneId == SCENE_EDIT_CONTACT_FORM)
                                {
                                        pSceneManager->GoBackward(BackwardSceneTransition(SCENE_MAIN_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
@@ -300,12 +296,11 @@ DetailViewForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousScen
        {
                __previousSceneId = previousSceneId;
 
-               result r = E_SUCCESS;
-
                Integer* pRecordId = static_cast <Integer*> (pArgs->GetAt(0));
                AppAssert(pRecordId);
 
                PersonId personId = pRecordId->ToInt();
+
                pArgs->RemoveAll(true);
                delete pArgs;
 
@@ -316,10 +311,10 @@ DetailViewForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousScen
                }
 
                __pPerson = __pAddressbookMgr->GetPersonN(personId);
-               r = GetLastResult();
-               TryReturnVoid(!IsFailed(r), "Failed to get the Person (%s).", GetErrorMessage(r));
-
-               GetContactsDetail();
+               if (__pPerson != null)
+               {
+                       GetContactsDetail();
+               }
        }
 }
 
@@ -501,26 +496,14 @@ DetailViewForm::ChangeFavoriteStatus(void)
        result r = E_SUCCESS;
        Header* pHeader = GetHeader();
 
-       Person* pPerson = __pAddressbookMgr->GetPersonN(__pPerson->GetId());
-       if (pPerson == null)
+       if (!IsPersonExistProcess())
        {
-               SceneManager* pSceneManager = SceneManager::GetInstance();
-               AppAssert(pSceneManager);
-
-               MessageBox messageBox;
-               messageBox.Construct(L"Error", "The person doesn't exist.", MSGBOX_STYLE_OK, 0);
-               int doModal;
-               messageBox.ShowAndWait(doModal);
-
-               pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
-
-               return r;
+               return E_FAILURE;
        }
 
-       if (pPerson->IsFavorite() == true)
+       if (__pPerson->IsFavorite() == true)
        {
-               r = pPerson->SetAsFavorite(false);
-               delete pPerson;
+               r = __pPerson->SetAsFavorite(false);
                TryReturn(!IsFailed(r), r, "Failed to set person as favorite. (%s)", GetErrorMessage(r));
 
                pHeader->SetButtonTextColor(BUTTON_ITEM_STATUS_NORMAL, __normalTextColor);
@@ -529,8 +512,7 @@ DetailViewForm::ChangeFavoriteStatus(void)
 
        else
        {
-               r = pPerson->SetAsFavorite(true);
-               delete pPerson;
+               r = __pPerson->SetAsFavorite(true);
                TryReturn(!IsFailed(r), r, "Failed to set person as favorite. (%s)", GetErrorMessage(r));
 
                pHeader->SetButtonTextColor(BUTTON_ITEM_STATUS_NORMAL, __favoriteTextColor);
@@ -541,3 +523,39 @@ DetailViewForm::ChangeFavoriteStatus(void)
 
        return r;
 }
+
+result
+DetailViewForm::IsPersonExistProcess(void)
+{
+       Person* pPerson = null;
+
+       if (__pPerson != null)
+       {
+               pPerson = __pAddressbookMgr->GetPersonN(__pPerson->GetId());
+               __pPerson = pPerson;
+       }
+
+       if (pPerson == null)
+       {
+               SceneManager* pSceneManager = SceneManager::GetInstance();
+               AppAssert(pSceneManager);
+
+               MessageBox messageBox;
+               messageBox.Construct(L"Error", "The person doesn't exist.", MSGBOX_STYLE_OK, 0);
+               int doModal;
+               messageBox.ShowAndWait(doModal);
+
+               if (__previousSceneId == SCENE_EDIT_CONTACT_FORM)
+               {
+                       pSceneManager->GoBackward(BackwardSceneTransition(SCENE_MAIN_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
+               }
+               else
+               {
+                       pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
+               }
+
+               return false;
+       }
+
+       return true;
+}