fix certificate popup crash issue
[framework/osp/web.git] / src / controls / FWebCtrl_WebImpl.cpp
index 47067cb..c308c2a 100755 (executable)
@@ -2213,13 +2213,6 @@ _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
 
 _WebImpl::~_WebImpl()
 {
-       _WebManager* pWebManager = _WebManager::GetInstance();
-       pWebManager->RemoveWeb(reinterpret_cast< int >(this));
-
-       _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
-       pManagerImpl->SetDownloadListener(null);
-
-       RemoveEventListenerCallback();
        ClearCertificateDb();
 }
 
@@ -2314,9 +2307,6 @@ _WebImpl::Construct(void)
        __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
        SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
 
-       _WebManager* pWebManager = _WebManager::GetInstance();
-       pWebManager->AddWeb(reinterpret_cast< int >(this));
-
        return E_SUCCESS;
 }
 
@@ -4867,12 +4857,35 @@ _WebImpl::OnPreAttachedToMainTree(void)
        r = __pWebCore->InitializeWebNativeNode();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
+       _ControlManager* pControlManager = _ControlManager::GetInstance();
+       SysTryReturnResult(NID_WEB_CTRL, pControlManager, E_SYSTEM, "Failed to get the ControlManager instance.");
+       OnChangeLayout(pControlManager->GetScreenRotation());
+
        r = InitializeSetting();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        r = _ContainerImpl::OnPreAttachedToMainTree();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
+       _WebManager* pWebManager = _WebManager::GetInstance();
+       pWebManager->AddWeb(reinterpret_cast< int >(this));
+
+       return E_SUCCESS;
+}
+
+
+result
+_WebImpl::OnDetachingFromMainTree(void)
+{
+       _WebManager* pWebManager = _WebManager::GetInstance();
+       pWebManager->RemoveWeb(reinterpret_cast< int >(this));
+       pWebManager->RemoveActiveWeb(this);     
+
+       _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
+       pManagerImpl->SetDownloadListener(null);
+
+       RemoveEventListenerCallback();
+
        return E_SUCCESS;
 }