Commit 2842a957 authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Clear class properties in ~View

This lets us make sure that the View (but not necessarily subclasses)
outlive their properties. Without this change accessing View in the
property destructor would be a use after free.

Bug: None
Change-Id: I8e783fbf46ed046bd2ac7e77ed2373c1da5758e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1828217Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Auto-Submit: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700483}
parent 4084096a
...@@ -143,6 +143,12 @@ View::~View() { ...@@ -143,6 +143,12 @@ View::~View() {
for (ui::Layer* layer_beneath : layers_beneath_) for (ui::Layer* layer_beneath : layers_beneath_)
layer_beneath->RemoveObserver(this); layer_beneath->RemoveObserver(this);
// Clearing properties explicitly here lets us guarantee that properties
// outlive |this| (at least the View part of |this|). This is intentionally
// called at the end so observers can examine properties inside
// OnViewIsDeleting(), for instance.
ClearProperties();
} }
// Tree operations ------------------------------------------------------------- // Tree operations -------------------------------------------------------------
......
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