Commit 73b5ddeb authored by mohan.reddy's avatar mohan.reddy Committed by Commit bot

Fix WeakPtrFactory member ordering in ui

Changing in the intialization order of WeakPtrFactory such that all
member variables should appear before the WeakPtrFactory to ensure
that any WeakPtrs to Controller are invalidated before its members
variable's destructors are executed, rendering them invalid.

BUG=303818

Review URL: https://codereview.chromium.org/589413002

Cr-Commit-Position: refs/heads/master@{#296468}
parent 51645a45
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "ui/aura/client/screen_position_client.h" #include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_property.h" #include "ui/aura/window_property.h"
DECLARE_WINDOW_PROPERTY_TYPE(aura::client::ScreenPositionClient*) DECLARE_WINDOW_PROPERTY_TYPE(aura::client::ScreenPositionClient*)
......
...@@ -166,13 +166,13 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, ...@@ -166,13 +166,13 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
ObserverList<KeyboardControllerObserver> observer_list_; ObserverList<KeyboardControllerObserver> observer_list_;
base::WeakPtrFactory<KeyboardController> weak_factory_;
// The currently used keyboard position. // The currently used keyboard position.
gfx::Rect current_keyboard_bounds_; gfx::Rect current_keyboard_bounds_;
static KeyboardController* instance_; static KeyboardController* instance_;
base::WeakPtrFactory<KeyboardController> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(KeyboardController); DISALLOW_COPY_AND_ASSIGN(KeyboardController);
}; };
......
...@@ -43,13 +43,13 @@ class AccessiblePaneViewFocusSearch : public FocusSearch { ...@@ -43,13 +43,13 @@ class AccessiblePaneViewFocusSearch : public FocusSearch {
AccessiblePaneView::AccessiblePaneView() AccessiblePaneView::AccessiblePaneView()
: pane_has_focus_(false), : pane_has_focus_(false),
allow_deactivate_on_esc_(false), allow_deactivate_on_esc_(false),
method_factory_(this),
focus_manager_(NULL), focus_manager_(NULL),
home_key_(ui::VKEY_HOME, ui::EF_NONE), home_key_(ui::VKEY_HOME, ui::EF_NONE),
end_key_(ui::VKEY_END, ui::EF_NONE), end_key_(ui::VKEY_END, ui::EF_NONE),
escape_key_(ui::VKEY_ESCAPE, ui::EF_NONE), escape_key_(ui::VKEY_ESCAPE, ui::EF_NONE),
left_key_(ui::VKEY_LEFT, ui::EF_NONE), left_key_(ui::VKEY_LEFT, ui::EF_NONE),
right_key_(ui::VKEY_RIGHT, ui::EF_NONE) { right_key_(ui::VKEY_RIGHT, ui::EF_NONE),
method_factory_(this) {
focus_search_.reset(new AccessiblePaneViewFocusSearch(this)); focus_search_.reset(new AccessiblePaneViewFocusSearch(this));
last_focused_view_storage_id_ = ViewStorage::GetInstance()->CreateStorageID(); last_focused_view_storage_id_ = ViewStorage::GetInstance()->CreateStorageID();
} }
......
...@@ -101,8 +101,6 @@ class VIEWS_EXPORT AccessiblePaneView : public View, ...@@ -101,8 +101,6 @@ class VIEWS_EXPORT AccessiblePaneView : public View,
// is known where to return to. // is known where to return to.
bool allow_deactivate_on_esc_; bool allow_deactivate_on_esc_;
base::WeakPtrFactory<AccessiblePaneView> method_factory_;
// Save the focus manager rather than calling GetFocusManager(), // Save the focus manager rather than calling GetFocusManager(),
// so that we can remove focus listeners in the destructor. // so that we can remove focus listeners in the destructor.
FocusManager* focus_manager_; FocusManager* focus_manager_;
...@@ -124,6 +122,8 @@ class VIEWS_EXPORT AccessiblePaneView : public View, ...@@ -124,6 +122,8 @@ class VIEWS_EXPORT AccessiblePaneView : public View,
friend class AccessiblePaneViewFocusSearch; friend class AccessiblePaneViewFocusSearch;
base::WeakPtrFactory<AccessiblePaneView> method_factory_;
DISALLOW_COPY_AND_ASSIGN(AccessiblePaneView); DISALLOW_COPY_AND_ASSIGN(AccessiblePaneView);
}; };
......
...@@ -253,14 +253,14 @@ DesktopNativeWidgetAura::DesktopNativeWidgetAura( ...@@ -253,14 +253,14 @@ DesktopNativeWidgetAura::DesktopNativeWidgetAura(
internal::NativeWidgetDelegate* delegate) internal::NativeWidgetDelegate* delegate)
: desktop_window_tree_host_(NULL), : desktop_window_tree_host_(NULL),
ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
close_widget_factory_(this),
content_window_container_(NULL), content_window_container_(NULL),
content_window_(new aura::Window(this)), content_window_(new aura::Window(this)),
native_widget_delegate_(delegate), native_widget_delegate_(delegate),
last_drop_operation_(ui::DragDropTypes::DRAG_NONE), last_drop_operation_(ui::DragDropTypes::DRAG_NONE),
restore_focus_on_activate_(false), restore_focus_on_activate_(false),
cursor_(gfx::kNullCursor), cursor_(gfx::kNullCursor),
widget_type_(Widget::InitParams::TYPE_WINDOW) { widget_type_(Widget::InitParams::TYPE_WINDOW),
close_widget_factory_(this) {
aura::client::SetFocusChangeObserver(content_window_, this); aura::client::SetFocusChangeObserver(content_window_, this);
aura::client::SetActivationChangeObserver(content_window_, this); aura::client::SetActivationChangeObserver(content_window_, this);
} }
......
...@@ -255,10 +255,6 @@ class VIEWS_EXPORT DesktopNativeWidgetAura ...@@ -255,10 +255,6 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
scoped_ptr<DesktopCaptureClient> capture_client_; scoped_ptr<DesktopCaptureClient> capture_client_;
// The following factory is used for calls to close the NativeWidgetAura
// instance.
base::WeakPtrFactory<DesktopNativeWidgetAura> close_widget_factory_;
// Child of the root, contains |content_window_|. // Child of the root, contains |content_window_|.
aura::Window* content_window_container_; aura::Window* content_window_container_;
...@@ -315,6 +311,10 @@ class VIEWS_EXPORT DesktopNativeWidgetAura ...@@ -315,6 +311,10 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
// See class documentation for Widget in widget.h for a note about type. // See class documentation for Widget in widget.h for a note about type.
Widget::InitParams::Type widget_type_; Widget::InitParams::Type widget_type_;
// The following factory is used for calls to close the NativeWidgetAura
// instance.
base::WeakPtrFactory<DesktopNativeWidgetAura> close_widget_factory_;
DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetAura); DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetAura);
}; };
......
...@@ -129,8 +129,7 @@ const char* kAtomsToCache[] = { ...@@ -129,8 +129,7 @@ const char* kAtomsToCache[] = {
DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( DesktopWindowTreeHostX11::DesktopWindowTreeHostX11(
internal::NativeWidgetDelegate* native_widget_delegate, internal::NativeWidgetDelegate* native_widget_delegate,
DesktopNativeWidgetAura* desktop_native_widget_aura) DesktopNativeWidgetAura* desktop_native_widget_aura)
: close_widget_factory_(this), : xdisplay_(gfx::GetXDisplay()),
xdisplay_(gfx::GetXDisplay()),
xwindow_(0), xwindow_(0),
x_root_window_(DefaultRootWindow(xdisplay_)), x_root_window_(DefaultRootWindow(xdisplay_)),
atom_cache_(xdisplay_, kAtomsToCache), atom_cache_(xdisplay_, kAtomsToCache),
...@@ -147,7 +146,8 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( ...@@ -147,7 +146,8 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11(
window_parent_(NULL), window_parent_(NULL),
window_shape_(NULL), window_shape_(NULL),
custom_window_shape_(false), custom_window_shape_(false),
urgency_hint_set_(false) { urgency_hint_set_(false),
close_widget_factory_(this) {
} }
DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() {
......
...@@ -239,8 +239,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 ...@@ -239,8 +239,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
void DelayedResize(const gfx::Size& size); void DelayedResize(const gfx::Size& size);
base::WeakPtrFactory<DesktopWindowTreeHostX11> close_widget_factory_;
// X11 things // X11 things
// The display and the native X window hosting the root window. // The display and the native X window hosting the root window.
XDisplay* xdisplay_; XDisplay* xdisplay_;
...@@ -339,6 +337,8 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 ...@@ -339,6 +337,8 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
base::CancelableCallback<void()> delayed_resize_task_; base::CancelableCallback<void()> delayed_resize_task_;
base::WeakPtrFactory<DesktopWindowTreeHostX11> close_widget_factory_;
DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11); DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11);
}; };
......
...@@ -76,10 +76,10 @@ NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) ...@@ -76,10 +76,10 @@ NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate)
: delegate_(delegate), : delegate_(delegate),
window_(new aura::Window(this)), window_(new aura::Window(this)),
ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
close_widget_factory_(this),
destroying_(false), destroying_(false),
cursor_(gfx::kNullCursor), cursor_(gfx::kNullCursor),
saved_window_state_(ui::SHOW_STATE_DEFAULT) { saved_window_state_(ui::SHOW_STATE_DEFAULT),
close_widget_factory_(this) {
aura::client::SetFocusChangeObserver(window_, this); aura::client::SetFocusChangeObserver(window_, this);
aura::client::SetActivationChangeObserver(window_, this); aura::client::SetActivationChangeObserver(window_, this);
} }
......
...@@ -209,10 +209,6 @@ class VIEWS_EXPORT NativeWidgetAura ...@@ -209,10 +209,6 @@ class VIEWS_EXPORT NativeWidgetAura
// See class documentation for Widget in widget.h for a note about ownership. // See class documentation for Widget in widget.h for a note about ownership.
Widget::InitParams::Ownership ownership_; Widget::InitParams::Ownership ownership_;
// The following factory is used for calls to close the NativeWidgetAura
// instance.
base::WeakPtrFactory<NativeWidgetAura> close_widget_factory_;
// Are we in the destructor? // Are we in the destructor?
bool destroying_; bool destroying_;
...@@ -230,6 +226,10 @@ class VIEWS_EXPORT NativeWidgetAura ...@@ -230,6 +226,10 @@ class VIEWS_EXPORT NativeWidgetAura
scoped_ptr<DropHelper> drop_helper_; scoped_ptr<DropHelper> drop_helper_;
int last_drop_operation_; int last_drop_operation_;
// The following factory is used for calls to close the NativeWidgetAura
// instance.
base::WeakPtrFactory<NativeWidgetAura> close_widget_factory_;
DISALLOW_COPY_AND_ASSIGN(NativeWidgetAura); DISALLOW_COPY_AND_ASSIGN(NativeWidgetAura);
}; };
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "ui/aura/client/focus_client.h" #include "ui/aura/client/focus_client.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/wm/core/window_modality_controller.h" #include "ui/wm/core/window_modality_controller.h"
#include "ui/wm/core/window_util.h" #include "ui/wm/core/window_util.h"
#include "ui/wm/public/activation_delegate.h" #include "ui/wm/public/activation_delegate.h"
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/env_observer.h" #include "ui/aura/env_observer.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/wm/core/shadow.h" #include "ui/wm/core/shadow.h"
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "ui/wm/core/window_util.h" #include "ui/wm/core/window_util.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/layer_tree_owner.h" #include "ui/compositor/layer_tree_owner.h"
#include "ui/wm/core/transient_window_manager.h" #include "ui/wm/core/transient_window_manager.h"
......
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