diff --git a/ui/ozone/platform/x11/x11_window.cc b/ui/ozone/platform/x11/x11_window.cc index 1366525c41b8d..e116be3274af8 100644 --- a/ui/ozone/platform/x11/x11_window.cc +++ b/ui/ozone/platform/x11/x11_window.cc @@ -1424,7 +1424,14 @@ uint32_t X11Window::DispatchEvent(const PlatformEvent& event) { auto& current_xevent = *connection_->dispatching_event(); if (event->IsMouseEvent()) { + // MouseOnWindow() -> OnCursorUpdate() can re-enter GetBoundsInPixels() via + // the Screen lookup and synchronously destroy `this` (see the warning at + // GetBoundsInPixels()). + auto weak_this = weak_ptr_factory_.GetWeakPtr(); X11WindowManager::GetInstance()->MouseOnWindow(this); + if (!weak_this) { + return POST_DISPATCH_STOP_PROPAGATION; + } } #if BUILDFLAG(USE_ATK) if (HandleAsAtkEvent(current_xevent)) {