Make Tilda work without DBus
authorIra W. Snyder <devel@irasnyder.com>
Wed, 30 Jan 2008 07:28:58 +0000 (23:28 -0800)
committerIra W. Snyder <devel@irasnyder.com>
Wed, 30 Jan 2008 07:33:28 +0000 (23:33 -0800)
If DBus is not running on the system, make Tilda work as usual,
minus the DBus IPC, of course. This makes many of the new features
unavailable, but at least Tilda does not crash.

Note that Tilda will still crash if you kill DBus out from underneath
it. I'm very sure this happens to most (all?) programs that use DBus
for IPC. Fortunately, DBus is very stable.

tilda-controller.c
tilda-terminal.c
tilda-window.c
tilda.c

index 7361ff8..4127920 100644 (file)
@@ -15,6 +15,10 @@ tilda_controller_dbus_register_object (TildaController *self)
 
        static const gchar object_path[] = "/net/sourceforge/Tilda";
 
+       /* If DBus is not running, leave */
+       if (!dbus_connection)
+               return;
+
        dbus_g_connection_register_g_object (dbus_connection, object_path, G_OBJECT(self));
 }
 
index 49b52e2..d7c6410 100644 (file)
@@ -182,7 +182,11 @@ tilda_terminal_dbus_register_object (TildaTerminal *tt)
        TildaWindow *parent_window = TILDA_WINDOW(tt->parent_window);
        gchar *object_path;
 
-       // Register this object with DBus
+       /* If DBus is not running, leave */
+       if (!dbus_connection)
+               return;
+
+       /* Register this object with DBus */
        object_path = g_strdup_printf ("/net/sourceforge/Tilda/Window%d/Terminal%d",
                                                                   parent_window->number, tt->number);
        dbus_g_connection_register_g_object (dbus_connection, object_path, G_OBJECT(tt));
index 351efa0..705a80a 100644 (file)
@@ -346,7 +346,11 @@ tilda_window_dbus_register_object (TildaWindow *self)
 
        gchar *object_path;
 
-       // Register this object with DBus
+       /* If DBus is not running, leave */
+       if (!dbus_connection)
+               return;
+
+       /* Register this object with DBus */
        object_path = g_strdup_printf ("/net/sourceforge/Tilda/Window%d", self->number);
        dbus_g_connection_register_g_object (dbus_connection, object_path, G_OBJECT(self));
        g_free (object_path);
diff --git a/tilda.c b/tilda.c
index 8b1de1d..617c5e2 100644 (file)
--- a/tilda.c
+++ b/tilda.c
@@ -7,7 +7,7 @@
 #include "tomboykeybinder.h"
 
 /* Project-global variables */
-DBusGConnection *dbus_connection;
+DBusGConnection *dbus_connection = NULL;
 
 static void
 tilda_dbus_init ()