[totem] Avoid crashes on exit



commit 24c12eb129fc66f3578f4b1317bc528640e522a1
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Apr 14 13:27:14 2010 +0100

    Avoid crashes on exit
    
    When the plugin viewer is set to exit, we don't want to receive
    messages on the bus, or we might crash. Just close the D-Bus
    connection before showing the error message.

 browser-plugin/totem-plugin-viewer.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/browser-plugin/totem-plugin-viewer.c b/browser-plugin/totem-plugin-viewer.c
index 331b40f..64c1338 100644
--- a/browser-plugin/totem-plugin-viewer.c
+++ b/browser-plugin/totem-plugin-viewer.c
@@ -102,6 +102,7 @@ typedef struct {
 typedef struct _TotemEmbedded {
 	GObject parent;
 
+	DBusGConnection *conn;
 	GtkWidget *window;
 	GtkBuilder *menuxml, *xml;
 	GtkWidget *about;
@@ -288,6 +289,12 @@ totem_embedded_exit (TotemEmbedded *emb)
 static void
 totem_embedded_error_and_exit (char *title, char *reason, TotemEmbedded *emb)
 {
+	/* Avoid any more contacts, so drop off the bus */
+	if (emb->conn != NULL) {
+		dbus_g_connection_unregister_g_object(emb->conn, G_OBJECT (emb));
+		emb->conn = NULL;
+	}
+
 	/* FIXME send a signal to the plugin with the error message instead! */
 	totem_interface_error_blocking (title, reason,
 			GTK_WINDOW (emb->window));
@@ -2390,8 +2397,10 @@ int main (int argc, char **argv)
         emb->referrer_uri = arg_referrer;
 
 	/* FIXME: register this BEFORE requesting the service name? */
-	dbus_g_connection_register_g_object
-	(conn, TOTEM_PLUGIN_VIEWER_DBUS_PATH, G_OBJECT (emb));
+	dbus_g_connection_register_g_object (conn,
+					     TOTEM_PLUGIN_VIEWER_DBUS_PATH,
+					     G_OBJECT (emb));
+	emb->conn = conn;
 
 	/* If we're hidden, construct a hidden window;
 	 * else wait to be plugged in.



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