Commit ae9628b6 authored by sadrul@chromium.org's avatar sadrul@chromium.org

views: Make sure the bubble-delegate removes itself from the anchor-widget's observer list.

This fixes a crash that shows up when terminating from the system tray popup.

BUG=105151,124310
TEST=WidgetObserverTest.DestroyBubble

Review URL: https://chromiumcodereview.appspot.com/10204014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133748 0039d316-1c4b-4281-b951-d872f2087c98
parent 90ce61b5
......@@ -167,6 +167,14 @@ BubbleDelegateView* BubbleDelegateView::AsBubbleDelegate() {
return this;
}
void BubbleDelegateView::WindowClosing() {
if (anchor_widget_) {
anchor_widget_->RemoveObserver(this);
anchor_widget_ = NULL;
anchor_view_ = NULL;
}
}
View* BubbleDelegateView::GetContentsView() {
return this;
}
......
......@@ -42,6 +42,7 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
// WidgetDelegate overrides:
virtual View* GetInitiallyFocusedView() OVERRIDE;
virtual BubbleDelegateView* AsBubbleDelegate() OVERRIDE;
virtual void WindowClosing() OVERRIDE;
virtual View* GetContentsView() OVERRIDE;
virtual NonClientFrameView* CreateNonClientFrameView(
views::Widget* widget) OVERRIDE;
......
......@@ -8,6 +8,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/point.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/test/test_views_delegate.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/views_delegate.h"
......@@ -738,6 +739,22 @@ TEST_F(WidgetObserverTest, DISABLED_VisibilityChange) {
toplevel->CloseNow();
}
TEST_F(WidgetObserverTest, DestroyBubble) {
Widget* anchor = CreateTopLevelPlatformWidget();
View* view = new View;
anchor->SetContentsView(view);
anchor->Show();
BubbleDelegateView* bubble_delegate =
new BubbleDelegateView(view, BubbleBorder::NONE);
Widget* bubble_widget(BubbleDelegateView::CreateBubble(bubble_delegate));
bubble_widget->Show();
bubble_widget->CloseNow();
anchor->Hide();
anchor->CloseNow();
}
#if !defined(USE_AURA) && defined(OS_WIN)
// Aura needs shell to maximize/fullscreen window.
// NativeWidgetGtk doesn't implement GetRestoredBounds.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment