From 8c59c7f4225c306cd9e6220d6b5b6cb7c609543e Mon Sep 17 00:00:00 2001 From: Hyunseok Yang Date: Fri, 12 Jul 2013 20:12:12 +0900 Subject: [PATCH] fixed tc error in GetEvasFromUiApp Change-Id: I89af9a068b0dc342782af2545a4b3c8e2bdc37ac Signed-off-by: Hyunseok Yang --- src/FWeb_BookmarkItemImpl.cpp | 43 +++++++++++++++++++++++---------- src/FWeb_HistoryItemImpl.cpp | 50 +++++++++++++++++++++++++++------------ src/FWeb_WebBookmarkImpl.cpp | 35 +++++++++++++++++++-------- src/controls/FWebCtrl_Utility.cpp | 21 ++++++++-------- src/controls/FWebCtrl_Utility.h | 7 +++++- 5 files changed, 106 insertions(+), 50 deletions(-) diff --git a/src/FWeb_BookmarkItemImpl.cpp b/src/FWeb_BookmarkItemImpl.cpp index 63bca69..3ad4240 100755 --- a/src/FWeb_BookmarkItemImpl.cpp +++ b/src/FWeb_BookmarkItemImpl.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "FWeb_BookmarkItemImpl.h" #include "FWebCtrl_Utility.h" @@ -35,6 +36,7 @@ using namespace Tizen::Base; using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; using namespace Tizen::Web::Controls; @@ -87,36 +89,51 @@ Bitmap* _BookmarkItemImpl::GetFaviconN(void) const { result r = E_SUCCESS; + Frame* pFrame = null; + Evas* pEvas = null; + Evas_Object* pIcon = null; + + BufferInfo bufferInfo; + ByteBuffer byteBuffer; - Evas* pEvas = _Utility::GetEvasFromUiApp(); - SysTryReturn(NID_WEB, pEvas, null, E_SYSTEM, "[E_SYSTEM] Propagating."); + std::unique_ptr pImage; + Dimension dimension; + int ret = 0; - Evas_Object* pIcon = null; - int ret = favorites_bookmark_get_favicon(__id, pEvas, &pIcon); - SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] Propagating."); + pEvas = _Utility::GetEvasFromUiApp(pFrame); + SysTryCatch(NID_WEB, pEvas, , E_SYSTEM, "[E_SYSTEM] Propagating."); + + ret = favorites_bookmark_get_favicon(__id, pEvas, &pIcon); + SysTryCatch(NID_WEB, ret == FAVORITES_ERROR_NONE, , E_SYSTEM, "[E_SYSTEM] Propagating."); if (!pIcon) { return null; } - BufferInfo bufferInfo; r = _Utility::GetPixelBufferFromEvasObject(pIcon, bufferInfo); - SysTryReturn(NID_WEB, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - const Dimension dimension(bufferInfo.width, bufferInfo.height); + dimension.width = bufferInfo.width; + dimension.height = bufferInfo.height; - ByteBuffer byteBuffer; r = byteBuffer.Construct(reinterpret_cast < byte* >(bufferInfo.pPixels), 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 ); - SysTryReturn(NID_WEB, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - std::unique_ptr pImage(new (std::nothrow) Bitmap()); - SysTryReturn(NID_WEB, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + pImage = std::unique_ptr(new (std::nothrow) Bitmap()); + SysTryCatch(NID_WEB, pImage.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888); - SysTryReturn(NID_WEB, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pFrame; return pImage.release(); + +CATCH: + delete pFrame; + + return null; } diff --git a/src/FWeb_HistoryItemImpl.cpp b/src/FWeb_HistoryItemImpl.cpp index 9315ff6..30b4f2c 100755 --- a/src/FWeb_HistoryItemImpl.cpp +++ b/src/FWeb_HistoryItemImpl.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "FWeb_HistoryItemImpl.h" #include "FWebCtrl_Utility.h" @@ -37,6 +38,7 @@ using namespace Tizen::Base; using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; using namespace Tizen::Web::Controls; @@ -84,22 +86,33 @@ Bitmap* _HistoryItemImpl::GetFaviconN(void) const { result r = E_SUCCESS; - - Evas* pEvas = _Utility::GetEvasFromUiApp(); - SysTryReturn(NID_WEB_CTRL, pEvas, null, E_SYSTEM, "[E_SYSTEM] Propagating."); + Frame* pFrame = null; Evas_Object* pIcon = null; + + Ewk_Context* pDefaultContext = null; + std::unique_ptr pUrl; + std::unique_ptr pBitmapImage; + + int ret = 0; + Dimension dimension; + BufferInfo bufferInfo; + ByteBuffer byteBuffer; + + Evas* pEvas = _Utility::GetEvasFromUiApp(pFrame); + SysTryCatch(NID_WEB_CTRL, pEvas, , E_SYSTEM, "[E_SYSTEM] Propagating."); + if( __id == -1) { - Ewk_Context* pDefaultContext = ewk_context_default_get(); + pDefaultContext = ewk_context_default_get(); - const std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(__url)); + pUrl = std::unique_ptr(_StringConverter::CopyToCharArrayN(__url)); pIcon = ewk_context_icon_database_icon_object_add(pDefaultContext, pUrl.get(), pEvas); } else { - int ret = favorites_history_get_favicon(__id, pEvas, &pIcon); - SysTryReturn(NID_WEB_CTRL, ret == FAVORITES_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] Propagating."); + ret = favorites_history_get_favicon(__id, pEvas, &pIcon); + SysTryCatch(NID_WEB_CTRL, ret == FAVORITES_ERROR_NONE, , E_SYSTEM, "[E_SYSTEM] Propagating."); } if (!pIcon) @@ -107,23 +120,30 @@ _HistoryItemImpl::GetFaviconN(void) const return null; } - BufferInfo bufferInfo; r = _Utility::GetPixelBufferFromEvasObject(pIcon, bufferInfo); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - const Dimension dimension(bufferInfo.width, bufferInfo.height); + dimension.width = bufferInfo.width; + dimension.height = bufferInfo.height; - ByteBuffer byteBuffer; r = byteBuffer.Construct(reinterpret_cast < byte* >(bufferInfo.pPixels), 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 ); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - std::unique_ptr pBitmapImage(new (std::nothrow) Bitmap()); - SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + pBitmapImage = std::unique_ptr(new (std::nothrow) Bitmap()); + SysTryCatch(NID_WEB_CTRL, pBitmapImage.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + + delete pFrame; return pBitmapImage.release(); + +CATCH: + delete pFrame; + + return null; } diff --git a/src/FWeb_WebBookmarkImpl.cpp b/src/FWeb_WebBookmarkImpl.cpp index 2b7632e..caed0aa 100755 --- a/src/FWeb_WebBookmarkImpl.cpp +++ b/src/FWeb_WebBookmarkImpl.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include "FWeb_BookmarkItemImpl.h" #include "FWeb_WebBookmarkImpl.h" #include "FWebCtrl_Utility.h" @@ -36,6 +37,7 @@ using namespace Tizen::Base; using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; using namespace Tizen::Web::Controls; @@ -144,32 +146,45 @@ _WebBookmarkImpl::SetFavicon(RecordId bookmarkId, const Bitmap& favicon) SysTryReturnResult(NID_WEB, favicon.GetPixelColorFormat() == BITMAP_PIXEL_FORMAT_ARGB8888, E_INVALID_DATA, "The pixel format of a favicon must be ARGB8888"); result r = E_SUCCESS; + Frame* pFrame = null; - Evas* pEvas = _Utility::GetEvasFromUiApp(); - SysTryReturn(NID_WEB, pEvas, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + BufferInfo bufferInfo; + int ret = 0; + + Evas_Object* pIcon = null; + + Bitmap& temp = const_cast< Bitmap& >(favicon);; + + Evas* pEvas = _Utility::GetEvasFromUiApp(pFrame); + SysTryCatch(NID_WEB, pEvas, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r)); - Evas_Object* pIcon = evas_object_image_filled_add(pEvas); + pIcon = evas_object_image_filled_add(pEvas); evas_object_image_colorspace_set(pIcon, EVAS_COLORSPACE_ARGB8888); evas_object_image_filled_set(pIcon, EINA_TRUE); evas_object_image_alpha_set(pIcon,EINA_TRUE); - Bitmap& temp = const_cast< Bitmap& >(favicon); - - BufferInfo bufferInfo; r = temp.Lock(bufferInfo); - SysTryReturn(NID_WEB, r == E_SUCCESS, r, r, "[%s] Propagating.", r); + SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", r); evas_object_image_size_set(pIcon, bufferInfo.width, bufferInfo.height); evas_object_image_fill_set(pIcon, 0, 0, bufferInfo.width, bufferInfo.height); evas_object_image_data_set(pIcon, bufferInfo.pPixels); r = temp.Unlock(); - SysTryReturn(NID_WEB, r == E_SUCCESS, r, r, "[%s] Propagating.", r); + SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", r); - int ret = favorites_bookmark_set_favicon(bookmarkId, pIcon); - SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, ConvertErrorCode(ret), ConvertErrorCode(ret), "[%s] Propagating.", GetErrorMessage(ConvertErrorCode(ret))); + ret = favorites_bookmark_set_favicon(bookmarkId, pIcon); + SysTryCatch(NID_WEB, ret == FAVORITES_ERROR_NONE, r = ConvertErrorCode(ret), r, "[%s] Propagating.", GetErrorMessage(r)); + + + delete pFrame; return E_SUCCESS; + +CATCH: + delete pFrame; + + return r; } diff --git a/src/controls/FWebCtrl_Utility.cpp b/src/controls/FWebCtrl_Utility.cpp index 78e7b2c..4684712 100755 --- a/src/controls/FWebCtrl_Utility.cpp +++ b/src/controls/FWebCtrl_Utility.cpp @@ -22,7 +22,6 @@ * The file contains the definition of _Utility class. */ -#include #include #include #include @@ -58,24 +57,24 @@ _Utility::~_Utility(void) Evas* -_Utility::GetEvasFromUiApp() +_Utility::GetEvasFromUiApp(Tizen::Ui::Controls::Frame* pTempFrame) { - std::unique_ptr pFrame; - + Frame* pFrame = null; + Evas* pEvas = null; if (_AppInfo::GetAppType() == _APP_TYPE_UI_APP) { IAppFrame* pAppFrame = Application::GetInstance()->GetAppFrame(); SysTryReturn(NID_WEB_CTRL, pAppFrame, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - pFrame = std::unique_ptr(pAppFrame->GetFrame()); - SysTryReturn(NID_WEB_CTRL, pFrame, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - pFrame.release(); + pFrame = pAppFrame->GetFrame(); + SysTryReturn(NID_WEB_CTRL, pFrame, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); } else { - pFrame = std::unique_ptr(new (std::nothrow) Frame()); - pFrame->Construct(Rectangle(0, 0, SEVICE_APP_FRAME_SIZE, SEVICE_APP_FRAME_SIZE)); + pFrame = new (std::nothrow) Frame(); + pFrame->Construct(Rectangle(0, 0, SEVICE_APP_FRAME_SIZE, SEVICE_APP_FRAME_SIZE)); + + pTempFrame = pFrame; } _ControlImpl* pControlimpl = _ControlImpl::GetInstance(*pFrame); @@ -90,7 +89,7 @@ _Utility::GetEvasFromUiApp() _EflNode* pEflNode = dynamic_cast< _EflNode* >(pWebVisualElementImpl->GetNativeNode()); SysTryReturn(NID_WEB_CTRL, pEflNode, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - Evas* pEvas = pEflNode->GetEvas(); + pEvas = pEflNode->GetEvas(); SysTryReturn(NID_WEB_CTRL, pEvas, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); return pEvas; diff --git a/src/controls/FWebCtrl_Utility.h b/src/controls/FWebCtrl_Utility.h index 65d4986..32955ad 100755 --- a/src/controls/FWebCtrl_Utility.h +++ b/src/controls/FWebCtrl_Utility.h @@ -28,13 +28,18 @@ #include #include +namespace Tizen { namespace Ui { namespace Controls +{ +class Frame; +}}} + namespace Tizen { namespace Web { namespace Controls { class _Utility { public: - static Evas* GetEvasFromUiApp(void); + static Evas* GetEvasFromUiApp(Tizen::Ui::Controls::Frame* pTempFrame); static result GetPixelBufferFromEvasObject(const Evas_Object* source, Tizen::Graphics::BufferInfo& bufferInfo); -- 2.7.4