window: Remove prefs listener in _unmanage instead of _finalize

After _unmanage the object is semantically dead even if technically it's not,
so remove the prefs listener here to prevent it being called for a dead
object.

In particular this fixes a crash when starting up gnome-shell with at least
one gimp utility window opened which causes mutter to create a MetaWindow for
it only to immediately get an UnmapNotify afterwards which causes mutter to
unmanage the MetaWindow. Afterwards prefs_changed_callback is called for this
dead MetaWindow and tries to dereference the window->monitor pointer which is
already NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=671087
This commit is contained in:
Rui Matos 2012-02-29 22:31:30 +01:00
parent e6b4a34daf
commit 860c2a6282

View File

@ -215,8 +215,6 @@ meta_window_finalize (GObject *object)
meta_icon_cache_free (&window->icon_cache);
meta_prefs_remove_listener (prefs_changed_callback, window);
g_free (window->sm_client_id);
g_free (window->wm_client_machine);
g_free (window->startup_id);
@ -1895,6 +1893,8 @@ meta_window_unmanage (MetaWindow *window,
meta_error_trap_pop (window->display);
meta_prefs_remove_listener (prefs_changed_callback, window);
g_signal_emit (window, window_signals[UNMANAGED], 0);
g_object_unref (window);