Index: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc |
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc |
index 37da13a326cb77550cf604e03d19f9f90330be26..2c4f085143092bf4517d226f06b3c13d6aa9b762 100644 |
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc |
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc |
@@ -210,6 +210,7 @@ class FocusManagerEventHandler : public ui::EventHandler { |
//////////////////////////////////////////////////////////////////////////////// |
// DesktopNativeWidgetAura, public: |
+int DesktopNativeWidgetAura::cursor_reference_count_ = 0; |
DesktopNativeCursorManager* DesktopNativeWidgetAura::native_cursor_manager_ = |
NULL; |
views::corewm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL; |
@@ -301,6 +302,15 @@ void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed( |
aura::client::SetCursorClient(root->window(), NULL); |
native_cursor_manager_->RemoveRootWindow(root); |
+ cursor_reference_count_--; |
+ if (cursor_reference_count_ == 0) { |
+ // We are the last DesktopNativeWidgetAura instance, and we are responsible |
+ // for cleaning up |cursor_manager_|. |
+ delete cursor_manager_; |
+ native_cursor_manager_ = NULL; |
+ cursor_manager_ = NULL; |
+ } |
sadrul
2014/01/15 22:15:01
This looks a bit hairy. Perhaps there could be a [
|
+ |
aura::client::SetScreenPositionClient(root->window(), NULL); |
position_client_.reset(); |
@@ -397,6 +407,7 @@ void DesktopNativeWidgetAura::InitNativeWidget( |
// |root_window_| must be added to |native_cursor_manager_| before |
// OnRootWindowCreated() is called. |
+ cursor_reference_count_++; |
if (!native_cursor_manager_) { |
native_cursor_manager_ = new DesktopNativeCursorManager( |
DesktopCursorLoaderUpdater::Create()); |