From: chitta ranjan Date: Fri, 5 Apr 2013 12:37:26 +0000 (+0900) Subject: Prevent defects fixes X-Git-Tag: accepted/tizen_2.1/20130425.023641~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb532f7fb70e6528cbdc4ce5550ac040c41324f3;p=apps%2Fosp%2FImageViewer.git Prevent defects fixes Change-Id: I1c5458bacebb4236080543ced8202bdfa3378cfe Signed-off-by: chitta ranjan --- diff --git a/src/IvImageCropForm.cpp b/src/IvImageCropForm.cpp index f5acc71..cdb63e8 100644 --- a/src/IvImageCropForm.cpp +++ b/src/IvImageCropForm.cpp @@ -105,36 +105,36 @@ ImageCropForm::OnInitializing(void) if (pPanel != null) { pSaveButton = static_cast(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(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(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; diff --git a/src/IvImageViewerApp.cpp b/src/IvImageViewerApp.cpp index a9c1788..c70fdfc 100644 --- a/src/IvImageViewerApp.cpp +++ b/src/IvImageViewerApp.cpp @@ -140,8 +140,11 @@ ImageViewerApp::OnForeground(void) } MainFrame* pMainFrame = dynamic_cast(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(GetFrameAt(0)); - pMainFrame->SetEnabled(enabled); + if (pMainFrame != null) + { + pMainFrame->SetEnabled(enabled); + } } diff --git a/src/IvImageViewerForm.cpp b/src/IvImageViewerForm.cpp index 4e8f8c4..786e9ac 100644 --- a/src/IvImageViewerForm.cpp +++ b/src/IvImageViewerForm.cpp @@ -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; }