Check for a valid pointer in all places where GetWebView() and GetWebViewHost() are directly used in order to prevent potential crashes after WM_DESTROY is processed (issue #84).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@97 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2010-08-31 14:10:31 +00:00
parent c439ed160f
commit 79134a77f2
4 changed files with 57 additions and 23 deletions

View File

@@ -46,6 +46,7 @@ LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message,
break;
case WM_DESTROY:
if (browser)
{
CefRefPtr<CefHandler> handler = browser->GetHandler();
if(handler.get()) {
@@ -56,6 +57,7 @@ LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message,
// Clean up anything associated with the WebViewHost widget.
browser->GetWebViewHost()->webwidget()->close();
browser->webviewhost_.reset();
// Clear the user data pointer.
win_util::SetWindowUserData(hwnd, NULL);
@@ -150,7 +152,9 @@ void CefBrowserImpl::UIT_CreateBrowser(const std::wstring& url)
void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
{
REQUIRE_UIT();
if (!host)
return;
if (enable)
::SetFocus(host->view_handle());
else if (::GetFocus() == host->view_handle())