[network-manager-applet/NMA_0_8] editor: don't crash on exit if session bus doesn't exit (rh #627615)



commit 4cee1fb3937e3166838dfe1dd45f293f385253db
Author: Dan Williams <dcbw redhat com>
Date:   Tue Aug 31 21:19:01 2010 -0500

    editor: don't crash on exit if session bus doesn't exit (rh #627615)

 src/connection-editor/main.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/src/connection-editor/main.c b/src/connection-editor/main.c
index c2e0b15..69543d9 100644
--- a/src/connection-editor/main.c
+++ b/src/connection-editor/main.c
@@ -255,15 +255,16 @@ main (int argc, char *argv[])
 
 	/* Inits the dbus-glib type system too */
 	bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-	proxy = dbus_g_proxy_new_for_name (bus,
-	                                   "org.freedesktop.DBus",
-	                                   "/org/freedesktop/DBus",
-	                                   "org.freedesktop.DBus");
-
-	/* Check for an existing instance on the bus */
-	if (proxy) {
-		if (try_existing_instance (bus, proxy, type))
-			goto exit;
+	if (bus) {
+		proxy = dbus_g_proxy_new_for_name (bus,
+		                                   "org.freedesktop.DBus",
+		                                   "/org/freedesktop/DBus",
+		                                   "org.freedesktop.DBus");
+		/* Check for an existing instance on the bus */
+		if (proxy) {
+			if (try_existing_instance (bus, proxy, type))
+				goto exit;
+		}
 	}
 
 	loop = g_main_loop_new (NULL, FALSE);
@@ -297,7 +298,8 @@ main (int argc, char *argv[])
 exit:
 	if (proxy)
 		g_object_unref (proxy);
-	dbus_g_connection_unref (bus);
+	if (bus)
+		dbus_g_connection_unref (bus);
 	return 0;
 }
 



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