Commit fb6bb253 authored by Richard Knoll's avatar Richard Knoll Committed by Commit Bot

Use ScopedObserver in AuraLinuxApplication

This adds a ScopedObserver for observing aura::Window so we properly
remove ourselves on destruction. Although the AuraLinuxApplication is a
singleton some aura::Window seems to outlive it during shutdown which
triggers a CHECK failure.

Bug: 1124773
Change-Id: I9601a67685ff5435c4e23fe23d85e0338a440f2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410129
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807020}
parent ed342d9f
......@@ -87,12 +87,11 @@ class AuraLinuxApplication : public ui::AXPlatformNodeDelegateBase,
return;
widgets_.push_back(widget);
observer_.Add(widget);
widget_observer_.Add(widget);
aura::Window* window = widget->GetNativeWindow();
if (!window)
return;
window->AddObserver(this);
if (window)
window_observer_.Add(window);
}
gfx::NativeViewAccessible GetNativeViewAccessible() override {
......@@ -104,7 +103,12 @@ class AuraLinuxApplication : public ui::AXPlatformNodeDelegateBase,
// WidgetObserver:
void OnWidgetDestroying(Widget* widget) override {
observer_.Remove(widget);
widget_observer_.Remove(widget);
aura::Window* window = widget->GetNativeWindow();
if (window && window_observer_.IsObserving(window))
window_observer_.Remove(window);
auto iter = std::find(widgets_.begin(), widgets_.end(), widget);
if (iter != widgets_.end())
widgets_.erase(iter);
......@@ -163,7 +167,8 @@ class AuraLinuxApplication : public ui::AXPlatformNodeDelegateBase,
ui::AXNodeData data_;
ui::AXUniqueId unique_id_;
std::vector<Widget*> widgets_;
ScopedObserver<views::Widget, views::WidgetObserver> observer_{this};
ScopedObserver<views::Widget, views::WidgetObserver> widget_observer_{this};
ScopedObserver<aura::Window, aura::WindowObserver> window_observer_{this};
};
} // namespace
......
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