[Galago-commits] r3034 - trunk/notification-daemon/src/daemon

galago-commits at freedesktop.org galago-commits at freedesktop.org
Sat Jun 13 16:29:13 PDT 2009


Author: chipx86
Date: 2009-06-13 16:29:12 -0700 (Sat, 13 Jun 2009)
New Revision: 3034

Modified:
   trunk/notification-daemon/src/daemon/daemon.c
   trunk/notification-daemon/src/daemon/engines.c
Log:
Patch by Vincent Untz to fix a crash in notification-daemon when changing
the theme.


Modified: trunk/notification-daemon/src/daemon/daemon.c
===================================================================
--- trunk/notification-daemon/src/daemon/daemon.c	2009-06-13 23:27:39 UTC (rev 3033)
+++ trunk/notification-daemon/src/daemon/daemon.c	2009-06-13 23:29:12 UTC (rev 3034)
@@ -77,6 +77,7 @@
 
 typedef struct
 {
+	NotifyDaemon *daemon;
 	GTimeVal expiration;
 	GTimeVal paused_diff;
 	gboolean has_timeout;
@@ -117,6 +118,7 @@
 #endif /* D-BUS < 0.60 */
 
 static void notify_daemon_finalize(GObject *object);
+static void _notification_destroyed_cb(GtkWindow *nw, NotifyDaemon *daemon);
 static void _close_notification(NotifyDaemon *daemon, guint id,
 								gboolean hide_notification,
 								NotifydClosedReason reason);
@@ -147,6 +149,14 @@
 static void
 _notify_timeout_destroy(NotifyTimeout *nt)
 {
+	/*
+	 * Disconnect the destroy handler to avoid a loop since the id
+	 * won't be removed from the hash table before the widget is
+	 * destroyed.
+	 */
+	g_signal_handlers_disconnect_by_func(nt->nw, _notification_destroyed_cb,
+										 nt->daemon);
+
 	gtk_widget_destroy(GTK_WIDGET(nt->nw));
 	g_free(nt);
 }
@@ -582,6 +592,7 @@
 	nt = g_new0(NotifyTimeout, 1);
 	nt->id = id;
 	nt->nw = nw;
+	nt->daemon = daemon;
 
 	_calculate_timeout(daemon, nt, timeout);
 

Modified: trunk/notification-daemon/src/daemon/engines.c
===================================================================
--- trunk/notification-daemon/src/daemon/engines.c	2009-06-13 23:27:39 UTC (rev 3033)
+++ trunk/notification-daemon/src/daemon/engines.c	2009-06-13 23:29:12 UTC (rev 3034)
@@ -114,13 +114,27 @@
 	g_free(engine);
 }
 
+static gboolean
+theme_engine_destroy(ThemeEngine *engine)
+{
+	destroy_engine(engine);
+	return FALSE;
+}
+
 static void
 theme_engine_unref(ThemeEngine *engine)
 {
 	engine->ref_count--;
 
 	if (engine->ref_count == 0)
-		destroy_engine(engine);
+		/*
+		 * Destroy the engine in an idle loop since the last reference
+		 * might have been the one of a notification which is being
+		 * destroyed and that still has references to the engine
+		 * module. This way, we're sure the notification is completely
+		 * destroyed before the engine is.
+		 */
+		g_idle_add((GSourceFunc) theme_engine_destroy, engine);
 }
 
 static void



More information about the galago-commits mailing list