Fix crash when destroying the browser window while a context menu is displayed.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1096 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2013-02-13 17:11:50 +00:00
parent 6604af5462
commit bb3a804033
1 changed files with 9 additions and 4 deletions

View File

@ -43,8 +43,10 @@ CefMenuCreator::~CefMenuCreator() {
} }
bool CefMenuCreator::IsShowingContextMenu() { bool CefMenuCreator::IsShowingContextMenu() {
content::RenderWidgetHostView* view = content::WebContents* web_contents = browser_->GetWebContents();
browser_->GetWebContents()->GetRenderWidgetHostView(); if (!web_contents)
return false;
content::RenderWidgetHostView* view = web_contents->GetRenderWidgetHostView();
return (view && view->IsShowingContextMenu()); return (view && view->IsShowingContextMenu());
} }
@ -159,9 +161,12 @@ void CefMenuCreator::MenuWillShow(CefRefPtr<CefMenuModelImpl> source) {
if (source.get() != model_.get()) if (source.get() != model_.get())
return; return;
content::WebContents* web_contents = browser_->GetWebContents();
if (!web_contents)
return;
// Notify the host before showing the context menu. // Notify the host before showing the context menu.
content::RenderWidgetHostView* view = content::RenderWidgetHostView* view = web_contents->GetRenderWidgetHostView();
browser_->GetWebContents()->GetRenderWidgetHostView();
if (view) if (view)
view->SetShowingContextMenu(true); view->SetShowingContextMenu(true);
} }