summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-05 15:04:18 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-05 15:04:18 +0000
commit94cc41988303b41d2bfff0042a07697225e7b4d9 (patch)
tree18761dca1afe91e1f564a6ad35a1dbed2b5101e0
parentc5b0b4a3feab5433134bbb0d394caa7421e77506 (diff)
downloadchromium_src-94cc41988303b41d2bfff0042a07697225e7b4d9.zip
chromium_src-94cc41988303b41d2bfff0042a07697225e7b4d9.tar.gz
chromium_src-94cc41988303b41d2bfff0042a07697225e7b4d9.tar.bz2
NULL-check before accessing toplevel_window_ to avoid race-condition crash.
To reliably reproduce (before this patch), run browser_tests --gtest_filter=ExtensionApiTest.ShowPageActionPopup and then move the mouse pointer outside of the browser window. BUG=none TEST=fixes ExtensionApiTest.ShowPageActionPopup Review URL: http://codereview.chromium.org/1555006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43612 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/info_bubble_gtk.cc10
-rw-r--r--chrome/browser/gtk/info_bubble_gtk.h3
2 files changed, 12 insertions, 1 deletions
diff --git a/chrome/browser/gtk/info_bubble_gtk.cc b/chrome/browser/gtk/info_bubble_gtk.cc
index beae5d4..abbaf5c 100644
--- a/chrome/browser/gtk/info_bubble_gtk.cc
+++ b/chrome/browser/gtk/info_bubble_gtk.cc
@@ -110,6 +110,7 @@ void InfoBubbleGtk::Init(GtkWindow* toplevel_window,
DCHECK(!window_);
toplevel_window_ = toplevel_window;
+ DCHECK(toplevel_window_);
rect_ = rect;
preferred_arrow_location_ = arrow_location;
@@ -258,6 +259,9 @@ InfoBubbleGtk::ArrowLocationGtk InfoBubbleGtk::GetArrowLocation(
}
bool InfoBubbleGtk::UpdateArrowLocation(bool force_move_and_reshape) {
+ if (!toplevel_window_)
+ return false;
+
gint toplevel_x = 0, toplevel_y = 0;
gdk_window_get_position(
GTK_WIDGET(toplevel_window_)->window, &toplevel_x, &toplevel_y);
@@ -294,6 +298,9 @@ void InfoBubbleGtk::UpdateWindowShape() {
}
void InfoBubbleGtk::MoveWindow() {
+ if (!toplevel_window_)
+ return;
+
gint toplevel_x = 0, toplevel_y = 0;
gdk_window_get_position(
GTK_WIDGET(toplevel_window_)->window, &toplevel_x, &toplevel_y);
@@ -316,7 +323,8 @@ void InfoBubbleGtk::MoveWindow() {
void InfoBubbleGtk::StackWindow() {
// Stack our window directly above the toplevel window.
- gtk_util::StackPopupWindow(window_, GTK_WIDGET(toplevel_window_));
+ if (toplevel_window_)
+ gtk_util::StackPopupWindow(window_, GTK_WIDGET(toplevel_window_));
}
void InfoBubbleGtk::Observe(NotificationType type,
diff --git a/chrome/browser/gtk/info_bubble_gtk.h b/chrome/browser/gtk/info_bubble_gtk.h
index 10274fa..e5601fd 100644
--- a/chrome/browser/gtk/info_bubble_gtk.h
+++ b/chrome/browser/gtk/info_bubble_gtk.h
@@ -172,6 +172,9 @@ class InfoBubbleGtk : public NotificationObserver {
GtkAccelGroup* accel_group_;
// The window for which we're being shown (and to which |rect_| is relative).
+ // Note that it's possible for |toplevel_window_| to be NULL if the
+ // window is destroyed before this object is destroyed, so it's important
+ // to check for that case.
GtkWindow* toplevel_window_;
// Provides an offset from |toplevel_window_|'s origin for MoveWindow() to