Commit b79d4760 authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

Fix WidgetTest.DestroyedWithCaptureViaEventMonitor flaky crash

ClosingView is destroyed during its call to Widget::CloseNow().
ClosingView::widget_ should not be accesses after calling CloseNow().

Bug: 895882
Test: No flaky crashes
Change-Id: I40bb3306e969332191fc7118a905eee5900f0f2e
Reviewed-on: https://chromium-review.googlesource.com/c/1283690Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600055}
parent 3cabcd8f
...@@ -1915,10 +1915,12 @@ class ClosingView : public View { ...@@ -1915,10 +1915,12 @@ class ClosingView : public View {
// View: // View:
void OnEvent(ui::Event* event) override { void OnEvent(ui::Event* event) override {
// Guard against attempting to close the widget twice. // Guard against closing twice and writing to freed memory.
if (widget_) if (widget_ && event->type() == ui::ET_MOUSE_PRESSED) {
widget_->CloseNow(); Widget* widget = widget_;
widget_ = nullptr; widget_ = nullptr;
widget->CloseNow();
}
} }
private: private:
......
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