Prevent defects fixes
authorchitta ranjan <chitta.rs@samsung.com>
Fri, 5 Apr 2013 12:37:26 +0000 (21:37 +0900)
committerchitta ranjan <chitta.rs@samsung.com>
Fri, 5 Apr 2013 12:37:26 +0000 (21:37 +0900)
Change-Id: I1c5458bacebb4236080543ced8202bdfa3378cfe
Signed-off-by: chitta ranjan <chitta.rs@samsung.com>
src/IvImageCropForm.cpp
src/IvImageViewerApp.cpp
src/IvImageViewerForm.cpp

index f5acc71..cdb63e8 100644 (file)
@@ -105,36 +105,36 @@ ImageCropForm::OnInitializing(void)
        if (pPanel != null)
        {
                pSaveButton = static_cast<Button*>(pPanel->GetControl(L"IDC_SAVE_BUTTON"));
-               if (pSaveButton != null)
+               if (pSaveButton != null && pSaveButtonBitmap != null)
                {
                        Point startPoint((pSaveButton->GetWidth() - pSaveButtonBitmap->GetWidth()) / 2,
                                        (pSaveButton->GetHeight() - pSaveButtonBitmap->GetHeight()) / 2);
                        pSaveButton->SetNormalBitmap(startPoint, *pSaveButtonBitmap);
                        pSaveButton->AddActionEventListener(*this);
                        pSaveButton->SetActionId(IDA_BUTTON_SAVE);
+                       delete pSaveButtonBitmap;
                }
 
                pCancelButton = static_cast<Button*>(pPanel->GetControl(L"IDC_CANCEL_BUTTON"));
-               if (pCancelButton != null)
+               if (pCancelButton != null && pCancelButtonBitmap != null)
                {
                        Point startPoint((pCancelButton->GetWidth() - pCancelButtonBitmap->GetWidth()) / 2,
                                        (pCancelButton->GetHeight() - pCancelButtonBitmap->GetHeight()) / 2);
                        pCancelButton->SetNormalBitmap(startPoint, *pCancelButtonBitmap);
                        pCancelButton->AddActionEventListener(*this);
                        pCancelButton->SetActionId(IDA_BUTTON_CANCEL);
+                       delete pCancelButtonBitmap;
                }
+               SetControlAlwaysOnTop(*pPanel, true);
                Label* pLabel = static_cast<Label*>(pPanel->GetControl(L"IDC_PANEL_LABEL"));
                if (pLabel != null)
                {
-                       SetControlAlwaysOnTop(*pPanel, true);
+                       SetControlAlwaysAtBottom(*pLabel, true);
                }
-               SetControlAlwaysAtBottom(*pLabel, true);
        }
        AddTouchEventListener(*this);
        AddOrientationEventListener(*this);
 
-       delete pSaveButtonBitmap;
-       delete pCancelButtonBitmap;
        delete pCWRotationButtonBitmap;
        delete pCCWRotationButtonBitmap;
        return r;
index a9c1788..c70fdfc 100644 (file)
@@ -140,8 +140,11 @@ ImageViewerApp::OnForeground(void)
        }
 
        MainFrame* pMainFrame = dynamic_cast<MainFrame*>(GetFrameAt(0));
-       pMainFrame->SetEnabled(true);
-       pMainFrame->Invalidate(true);
+       if (pMainFrame != null)
+       {
+               pMainFrame->SetEnabled(true);
+               pMainFrame->Invalidate(true);
+       }
 
        SceneManager* pSceneManager = SceneManager::GetInstance();
        AppAssert(pSceneManager);
@@ -244,5 +247,8 @@ void
 ImageViewerApp::SetFrameEnabled(bool enabled)
 {
        MainFrame* pMainFrame = dynamic_cast<MainFrame*>(GetFrameAt(0));
-       pMainFrame->SetEnabled(enabled);
+       if (pMainFrame != null)
+       {
+               pMainFrame->SetEnabled(enabled);
+       }
 }
index 4e8f8c4..786e9ac 100644 (file)
@@ -1433,7 +1433,6 @@ ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
                __pPresentationModel->SetImageRotateStatus(true);
                RotateImage(filePath, rotateMode);
                __pPresentationModel->RequestImage(filePath);
-               //Invalidate(true);
                ContentManager::ScanFile(filePath);
        }
        break;
@@ -1445,7 +1444,6 @@ ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
                __pPresentationModel->SetImageRotateStatus(true);
                RotateImage(filePath, rotateMode);
                __pPresentationModel->RequestImage(filePath);
-               //Invalidate(true);
                ContentManager::ScanFile(filePath);
        }
        break;
@@ -1567,40 +1565,35 @@ void
 ImageViewerForm::RotateImage(String& filePath, RotateMode rotateMode)
 {
        result r = E_SUCCESS;
+       ImageBuffer rotateBuffer;
        ImageBuffer* pRotatedBuffer = null;
-       ImageBuffer* pRotatedBuffer1 = null;
        ImageFormat imageFormat;
-       int width = 0;
-       int height = 0;
-       pRotatedBuffer = new (std::nothrow) ImageBuffer();
-       r = pRotatedBuffer->Construct(filePath);
-       pRotatedBuffer->GetImageInfo(filePath, imageFormat, width, height);
+       Image img;
+       r = img.Construct();
+       if (r == E_SUCCESS)
+       {
+               imageFormat = img.GetImageFormat(filePath);
+       }
+       r = rotateBuffer.Construct(filePath);
+
+       //ImageBuffer::GetImageInfo(filePath, imageFormat, width, height);
        if (r == E_SUCCESS)
        {
                if (rotateMode == ROTATE_MODE_RIGHT)
                {
-                       pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_90);
+                       pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_90);
                }
                else
                {
-                       pRotatedBuffer1 = pRotatedBuffer->RotateN(IMAGE_ROTATION_270);
+                       pRotatedBuffer = rotateBuffer.RotateN(IMAGE_ROTATION_270);
                }
        }
-       TryCatch(pRotatedBuffer1 != null, r = GetLastResult(), "RotateN failed:%s", GetErrorMessage(GetLastResult()));
-       pRotatedBuffer1->EncodeToFile(filePath, imageFormat, true, 100);
-       delete pRotatedBuffer1;
-       delete pRotatedBuffer;
-       return;
 
-       CATCH:
-       if (pRotatedBuffer != null) //this buffer is no longer used
+       if (pRotatedBuffer != null)
        {
+               r = pRotatedBuffer->EncodeToFile(filePath, imageFormat, true, 100);
                delete pRotatedBuffer;
        }
-       if (pRotatedBuffer1 != null) //this buffer is no longer used
-       {
-               delete pRotatedBuffer1;
-       }
        return;
 }