aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--src/ephy-dbus.c23
-rw-r--r--src/ephy-net-monitor.c5
3 files changed, 30 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index f55555b52..c3d428b09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-04-03 Christian Persch <chpe@cvs.gnome.org>
+
+ * 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.
+
2006-04-02 Christian Persch <chpe@cvs.gnome.org>
* lib/ephy-gui.c: (ephy_gui_help_with_doc_id), (ephy_gui_help):
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;
}
diff --git a/src/ephy-net-monitor.c b/src/ephy-net-monitor.c
index df550bb5e..a087d151c 100644
--- a/src/ephy-net-monitor.c
+++ b/src/ephy-net-monitor.c
@@ -103,6 +103,8 @@ ephy_net_monitor_check_for_active_device (EphyNetMonitor *monitor,
NMActStage act_stage = NM_ACT_STAGE_UNKNOWN;
NetworkStatus status = NETWORK_DOWN;
+ if (priv->bus == NULL) return NETWORK_UP;
+
for (i = 0; i < num; i++)
{
const char *path = all_path [i];
@@ -338,7 +340,7 @@ ephy_net_monitor_attach_to_dbus (EphyNetMonitor *monitor)
dbus = ephy_dbus_get_default ();
g_connection = ephy_dbus_get_bus (dbus, EPHY_DBUS_SYSTEM);
- g_return_if_fail (g_connection != NULL);
+ if (g_connection == NULL) return;
priv->bus = dbus_g_connection_get_connection (g_connection);
@@ -408,7 +410,6 @@ ephy_net_monitor_startup (EphyNetMonitor *monitor)
g_signal_connect (dbus, "disconnected",
G_CALLBACK (disconnect_from_system_bus_cb), monitor);
- /* FIXME what if the system bus isn't available right now? */
ephy_net_monitor_check_network (monitor);
}