Index: ash/system/tray/tray_bubble_wrapper.cc |
diff --git a/ash/system/tray/tray_bubble_wrapper.cc b/ash/system/tray/tray_bubble_wrapper.cc |
index 75651c256a5f888107293a3d62c97b78bd306901..c57cc7a009240ab1571250ca66ef94e7fc372a25 100644 |
--- a/ash/system/tray/tray_bubble_wrapper.cc |
+++ b/ash/system/tray/tray_bubble_wrapper.cc |
@@ -7,6 +7,9 @@ |
#include "ash/system/tray/tray_background_view.h" |
#include "ash/system/tray/tray_event_filter.h" |
#include "ash/wm/window_properties.h" |
+#include "base/bind.h" |
+#include "base/message_loop.h" |
+#include "base/time.h" |
#include "ui/views/bubble/tray_bubble_view.h" |
#include "ui/views/widget/widget.h" |
@@ -17,6 +20,7 @@ TrayBubbleWrapper::TrayBubbleWrapper(TrayBackgroundView* tray, |
views::TrayBubbleView* bubble_view) |
: tray_(tray), |
bubble_view_(bubble_view) { |
+ DCHECK(tray_); |
bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); |
bubble_widget_->AddObserver(this); |
bubble_widget_->GetNativeView()-> |
@@ -40,7 +44,14 @@ TrayBubbleWrapper::~TrayBubbleWrapper() { |
void TrayBubbleWrapper::OnWidgetDestroying(views::Widget* widget) { |
CHECK_EQ(bubble_widget_, widget); |
bubble_widget_ = NULL; |
- tray_->HideBubbleWithView(bubble_view_); // May destroy |bubble_view_| |
+ |
+ // Do not call HideBubbleWithView directly but post the task to ensure that |
+ // HideBubbleWithView is called after the click event on the tray button is |
+ // handled. See crbug.com/177075 and crbug.com/169940 |
+ MessageLoopForUI::current()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&TrayBackgroundView::HideBubbleWithView, |
+ base::Unretained(tray_), base::Unretained(bubble_view_))); |
stevenjb
2013/03/06 02:35:26
Is there any possibility that tray_ or bubble_view
Jun Mukai
2013/03/06 04:36:57
Good catch. It's really unlikely but it may happen
|
} |
} // namespace internal |