69 lines
2.0 KiB
Diff
69 lines
2.0 KiB
Diff
diff --git ui/gfx/x/connection.cc ui/gfx/x/connection.cc
|
|
index e9034ec7dea3e..b11df74c1d9dd 100644
|
|
--- ui/gfx/x/connection.cc
|
|
+++ ui/gfx/x/connection.cc
|
|
@@ -183,6 +183,7 @@ Connection::Connection(const std::string& address)
|
|
Connection::~Connection() {
|
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
|
|
|
+ window_event_manager_.Reset();
|
|
platform_event_source.reset();
|
|
}
|
|
|
|
diff --git ui/gfx/x/window_event_manager.cc ui/gfx/x/window_event_manager.cc
|
|
index 7aee20ec3d2b7..9b5b320402ff8 100644
|
|
--- ui/gfx/x/window_event_manager.cc
|
|
+++ ui/gfx/x/window_event_manager.cc
|
|
@@ -113,10 +113,18 @@ WindowEventManager::WindowEventManager(Connection* connection)
|
|
: connection_(connection) {}
|
|
|
|
WindowEventManager::~WindowEventManager() {
|
|
+ Reset();
|
|
+}
|
|
+
|
|
+void WindowEventManager::Reset() {
|
|
+ if (!connection_) {
|
|
+ return;
|
|
+ }
|
|
// Clear events still requested by not-yet-deleted ScopedEventSelectors.
|
|
for (const auto& mask_pair : mask_map_) {
|
|
SetEventMask(connection_, mask_pair.first, EventMask::NoEvent);
|
|
}
|
|
+ connection_ = nullptr;
|
|
}
|
|
|
|
void WindowEventManager::SelectEvents(Window window, EventMask event_mask) {
|
|
@@ -143,7 +151,9 @@ void WindowEventManager::AfterMaskChanged(Window window, EventMask old_mask) {
|
|
return;
|
|
}
|
|
|
|
- SetEventMask(connection_, window, new_mask);
|
|
+ if (connection_) {
|
|
+ SetEventMask(connection_, window, new_mask);
|
|
+ }
|
|
|
|
if (new_mask == EventMask::NoEvent) {
|
|
mask_map_.erase(window);
|
|
diff --git ui/gfx/x/window_event_manager.h ui/gfx/x/window_event_manager.h
|
|
index 4b85f49d3b2cc..c0158edd6901b 100644
|
|
--- ui/gfx/x/window_event_manager.h
|
|
+++ ui/gfx/x/window_event_manager.h
|
|
@@ -53,6 +53,8 @@ class WindowEventManager {
|
|
|
|
~WindowEventManager();
|
|
|
|
+ void Reset();
|
|
+
|
|
private:
|
|
friend class ScopedEventSelector;
|
|
|
|
@@ -70,7 +72,7 @@ class WindowEventManager {
|
|
// necessary.
|
|
void AfterMaskChanged(Window window, EventMask old_mask);
|
|
|
|
- const raw_ptr<Connection> connection_;
|
|
+ raw_ptr<Connection> connection_;
|
|
|
|
std::map<Window, std::unique_ptr<MultiMask>> mask_map_;
|
|
};
|