diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-15 04:07:57 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-15 04:07:57 +0000 |
commit | b5dead81ae7c9324772755a14153258083c8aacb (patch) | |
tree | 404528b1c9c6012523aa43610996304e10f8b2b0 /ash/accelerators | |
parent | a11c5b6f8af29722d014f94d86ac0e4559b1f8f4 (diff) | |
download | chromium_src-b5dead81ae7c9324772755a14153258083c8aacb.zip chromium_src-b5dead81ae7c9324772755a14153258083c8aacb.tar.gz chromium_src-b5dead81ae7c9324772755a14153258083c8aacb.tar.bz2 |
Fix two crash and potential leak&crash
* closing window while menu is open
This only fix part of this. There is another place that crashes and i'll address it in separate CL.
* closing window while modal dialog is open
* release resources early and use window::Close in BallonViewImpl
This was causing crash if the widget gets closed earlier than
DelayedClose task is executed.
BUG=114123
TEST=none
Review URL: http://codereview.chromium.org/9348113
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122028 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/accelerators')
-rw-r--r-- | ash/accelerators/accelerator_dispatcher.cc | 12 | ||||
-rw-r--r-- | ash/accelerators/accelerator_dispatcher.h | 8 | ||||
-rw-r--r-- | ash/accelerators/accelerator_dispatcher_linux.cc | 2 | ||||
-rw-r--r-- | ash/accelerators/accelerator_dispatcher_win.cc | 2 |
4 files changed, 22 insertions, 2 deletions
diff --git a/ash/accelerators/accelerator_dispatcher.cc b/ash/accelerators/accelerator_dispatcher.cc index c72fdc2..47dde9c 100644 --- a/ash/accelerators/accelerator_dispatcher.cc +++ b/ash/accelerators/accelerator_dispatcher.cc @@ -11,7 +11,17 @@ AcceleratorDispatcher::AcceleratorDispatcher( : nested_dispatcher_(nested_dispatcher), associated_window_(associated_window) { DCHECK(nested_dispatcher_); - DCHECK(associated_window_); + associated_window_->AddObserver(this); +} + +AcceleratorDispatcher::~AcceleratorDispatcher() { + if (associated_window_) + associated_window_->RemoveObserver(this); +} + +void AcceleratorDispatcher::OnWindowDestroying(aura::Window* window) { + if (associated_window_ == window) + associated_window_ = NULL; } } // namespace ash diff --git a/ash/accelerators/accelerator_dispatcher.h b/ash/accelerators/accelerator_dispatcher.h index af75f48..209b67d 100644 --- a/ash/accelerators/accelerator_dispatcher.h +++ b/ash/accelerators/accelerator_dispatcher.h @@ -9,6 +9,7 @@ #include "ash/ash_export.h" #include "base/message_loop.h" #include "ui/aura/window.h" +#include "ui/aura/window_observer.h" namespace ash { @@ -16,10 +17,12 @@ namespace ash { // Wraps a nested dispatcher to which control is passed if no accelerator key // has been pressed. // TODO(pkotwicz): Port AcceleratorDispatcher to mac. -class ASH_EXPORT AcceleratorDispatcher : public MessageLoop::Dispatcher { +class ASH_EXPORT AcceleratorDispatcher : public MessageLoop::Dispatcher, + public aura::WindowObserver { public: explicit AcceleratorDispatcher(MessageLoop::Dispatcher* nested_dispatcher, aura::Window* associated_window); + virtual ~AcceleratorDispatcher(); #if defined(USE_X11) virtual base::MessagePumpDispatcher::DispatchStatus Dispatch( @@ -28,6 +31,9 @@ class ASH_EXPORT AcceleratorDispatcher : public MessageLoop::Dispatcher { bool AcceleratorDispatcher::Dispatch(const MSG& msg) OVERRIDE; #endif + // aura::WindowObserver overrides: + virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; + private: MessageLoop::Dispatcher* nested_dispatcher_; diff --git a/ash/accelerators/accelerator_dispatcher_linux.cc b/ash/accelerators/accelerator_dispatcher_linux.cc index 91fa80c..76a5767 100644 --- a/ash/accelerators/accelerator_dispatcher_linux.cc +++ b/ash/accelerators/accelerator_dispatcher_linux.cc @@ -28,6 +28,8 @@ const int kModifierMask = (ui::EF_SHIFT_DOWN | base::MessagePumpDispatcher::DispatchStatus AcceleratorDispatcher::Dispatch( XEvent* xev) { + if (!associated_window_) + return EVENT_QUIT; if (!associated_window_->CanReceiveEvents()) return aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch(xev); diff --git a/ash/accelerators/accelerator_dispatcher_win.cc b/ash/accelerators/accelerator_dispatcher_win.cc index 162d44f..fca6d049 100644 --- a/ash/accelerators/accelerator_dispatcher_win.cc +++ b/ash/accelerators/accelerator_dispatcher_win.cc @@ -20,6 +20,8 @@ const int kModifierMask = (ui::EF_SHIFT_DOWN | } // namespace bool AcceleratorDispatcher::Dispatch(const MSG& msg) { + if (!associated_window_) + return false; if (!associated_window_->CanReceiveEvents()) return aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch(msg); |