From: Seongjun Yim Date: Fri, 10 May 2013 14:21:32 +0000 (+0900) Subject: fix crash issue X-Git-Tag: submit/tizen_2.1/20130514.054703^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=20e1cae79800dfab10802121c6cdd499d828c348;p=framework%2Fosp%2Fweb.git fix crash issue Change-Id: I0daadb031f45b9696c321c7c08efae346bbc2f4b Signed-off-by: Seongjun Yim --- diff --git a/inc/FWebCtrlWeb.h b/inc/FWebCtrlWeb.h index ce14a5c..148f3d4 100755 --- a/inc/FWebCtrlWeb.h +++ b/inc/FWebCtrlWeb.h @@ -424,7 +424,7 @@ public: * @privilege %http://tizen.org/privilege/web.service * * @return The result of the evaluated JavaScript, @n - * else an empty string if an error occurs + * else null if an error occurs * @param[in] scriptCode The JavaScript code as string * @exception E_SUCCESS The method is successful. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. diff --git a/src/controls/FWebCtrl_WebImpl.cpp b/src/controls/FWebCtrl_WebImpl.cpp index 39855d0..1894dbc 100755 --- a/src/controls/FWebCtrl_WebImpl.cpp +++ b/src/controls/FWebCtrl_WebImpl.cpp @@ -1911,7 +1911,11 @@ OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData) String result(pResult); SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer()); - pPresenter->EndAsyncProcess(result); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL)); + if (pImpl && pImpl->IsPresenterAlived(pPresenter)) + { + pPresenter->EndAsyncProcess(result); + } } @@ -2134,6 +2138,9 @@ _WebImpl::Construct(void) r = __textSearch.__searchQueue.Construct(); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __callbackList.Construct(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = InitJsBridgeList(); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); @@ -2443,27 +2450,42 @@ _WebImpl::Reload(void) const String* -_WebImpl::EvaluateJavascriptN(const String& scriptCode) const +_WebImpl::EvaluateJavascriptN(const String& scriptCode) { - if (scriptCode.GetLength()) + if (scriptCode.GetLength() == 0) { - std::unique_ptr pScript(_StringConverter::CopyToCharArrayN(scriptCode)); - SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + return null; + } + + result r = E_SUCCESS; - std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter()); - SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - pPresenter->InitAsyncProcess(); + std::unique_ptr pScript(_StringConverter::CopyToCharArrayN(scriptCode)); + SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, pPresenter.get()); + std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter()); + SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - std::unique_ptr pResult(new (std::nothrow) String(L"")); - SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - pPresenter->WaitAsyncProcess(*pResult.get()); + r = __callbackList.Add(pPresenter.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - return pResult.release(); - } + ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, pPresenter.get()); - return null; + std::unique_ptr pResult(new (std::nothrow) String(L"")); + SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + pPresenter->WaitAsyncProcess(*pResult.get()); + + r = __callbackList.Remove(*pPresenter.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + pPresenter.release(); + + return pResult.release(); +} + + +bool +_WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const +{ + return __callbackList.Contains(*pPresenter); } diff --git a/src/controls/FWebCtrl_WebImpl.h b/src/controls/FWebCtrl_WebImpl.h index 983e2c6..1c61205 100755 --- a/src/controls/FWebCtrl_WebImpl.h +++ b/src/controls/FWebCtrl_WebImpl.h @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -191,7 +192,7 @@ public: Tizen::Base::String GetTextFromBlock(void) const; - Tizen::Base::String* EvaluateJavascriptN(const Tizen::Base::String& scriptCode) const; + Tizen::Base::String* EvaluateJavascriptN(const Tizen::Base::String& scriptCode); bool IsPrivateBrowsingEnabled(void) const; @@ -330,6 +331,7 @@ public: void SetKeypadOpened(bool isKeypadOpened); + bool IsPresenterAlived(_WebPresenter* pPresenter) const; Tizen::Graphics::Rectangle GetPreviousKeypadBounds(void) const; void SetPreviousKeypadBounds(Tizen::Graphics::Rectangle& bounds); @@ -454,6 +456,8 @@ private: _TextSearch __textSearch; + Tizen::Base::Collection::ArrayList __callbackList; + DecisionPolicy __policy; Tizen::Base::String __defaultUserAgent;