core: prevent early MetaIdleMonitor destruction when its invoker vanishes

If the last reference of a MetaIdleMonitor is held by the caller, it may
happen that the last reference is lost when calling the GDestroyNotify,
if this happens when the watched DBus name vanishes, the object (and the
watches hashtable) are destroyed while manipulating the watches hashtable,
so bad things may happen then.

Fix this by wrapping the operation by a ref/unref pair, so the object would
be destroyed after operating on the hashtable.

https://bugzilla.gnome.org/show_bug.cgi?id=724969
This commit is contained in:
Carlos Garnacho 2014-02-22 20:16:28 +01:00 committed by Rui Matos
parent 04b5232960
commit bcd5446cdc

View File

@ -653,8 +653,10 @@ meta_idle_monitor_remove_watch (MetaIdleMonitor *monitor,
{ {
g_return_if_fail (META_IS_IDLE_MONITOR (monitor)); g_return_if_fail (META_IS_IDLE_MONITOR (monitor));
g_object_ref (monitor);
g_hash_table_remove (monitor->watches, g_hash_table_remove (monitor->watches,
GUINT_TO_POINTER (id)); GUINT_TO_POINTER (id));
g_object_unref (monitor);
} }
/** /**