[mutter] window: Assert we have an up to date monitor after they changed



commit 4af4b79123ffcd5f8c289057993aae9b9dc241a9
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Mon Nov 11 11:01:43 2019 +0100

    window: Assert we have an up to date monitor after they changed
    
    Add an assert that we don't have a MetaWindow::monitor pointer that
    points to an old MetaLogicalMonitor. After this, and the other
    monitors-changed callbacks have been called, the old MetaLogicalMonitor
    will be destoryed, thus if we didn't update the pointer here, we'll
    point to freed memory, and will eventually crash later on.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/929

 src/core/window.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index 9dacdd2de..7eb2fc444 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -3915,7 +3915,7 @@ meta_window_update_for_monitors_changed (MetaWindow *window)
     {
       meta_window_update_monitor (window,
                                   META_WINDOW_UPDATE_MONITOR_FLAGS_FORCE);
-      return;
+      goto out;
     }
 
   old = window->monitor;
@@ -3958,6 +3958,11 @@ meta_window_update_for_monitors_changed (MetaWindow *window)
       meta_window_update_monitor (window,
                                   META_WINDOW_UPDATE_MONITOR_FLAGS_FORCE);
     }
+
+out:
+  g_assert (!window->monitor ||
+            g_list_find (meta_monitor_manager_get_logical_monitors (monitor_manager),
+                         window->monitor));
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]