From d25608d94a39a9bbb5ec4770e1da6b68d420bb5b Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Mon, 3 Apr 2006 11:56:01 +0000 Subject: Don't crash when we cannot connect to the system dbus. Bug #336557. 2006-04-03 Christian Persch * src/ephy-dbus.c: (ephy_dbus_get_bus): * src/ephy-net-monitor.c: (ephy_net_monitor_check_for_active_device), (ephy_net_monitor_attach_to_dbus), (ephy_net_monitor_startup): Don't crash when we cannot connect to the system dbus. Bug #336557. --- src/ephy-dbus.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/ephy-dbus.c') diff --git a/src/ephy-dbus.c b/src/ephy-dbus.c index 7ab1e81d4..1acd940a4 100644 --- a/src/ephy-dbus.c +++ b/src/ephy-dbus.c @@ -484,10 +484,19 @@ ephy_dbus_get_default (void) return ephy_dbus_instance; } +/** + * ephy_dbus_get_bus: + * @dbus: + * @kind: + * + * Returns: the #DBusGConnection for the @kind DBUS, or %NULL + * if a connection could not be established. + */ DBusGConnection * ephy_dbus_get_bus (EphyDbus *dbus, EphyDbusBus kind) { + EphyDbusPrivate *priv = dbus->priv; DBusGConnection *bus = NULL; g_return_val_if_fail (EPHY_IS_DBUS (dbus), NULL); @@ -495,23 +504,27 @@ ephy_dbus_get_bus (EphyDbus *dbus, if (kind == EPHY_DBUS_SYSTEM) { /* We connect lazily to the system bus */ - if (dbus->priv->system_bus == NULL) + if (priv->system_bus == NULL) { ephy_dbus_connect_to_system_bus (dbus, NULL); } - bus = dbus->priv->system_bus; + + bus = priv->system_bus; } else if (kind == EPHY_DBUS_SESSION) { - bus = dbus->priv->session_bus; + if (priv->session_bus == NULL) + { + ephy_dbus_connect_to_session_bus (dbus, NULL); + } + + bus = priv->session_bus; } else { g_assert_not_reached (); } - g_assert (bus != NULL); - return bus; } -- cgit v1.2.3