libnm-glib: allow NMRemoteSettings constructor with NULL bus

NMRemoteSettings's constructor requires a DBusGConnection, but there
currently aren't any usable gobject-introspection bindings for that class.
This means that NMRemoteSettings can't be used over gobject-introspection.

Move the default fallback to the system bus into the constructor path, so
that introspection bindings are usable.

Python test case:
	from gi.repository import NMClient
	NMClient.RemoteSettings()

Before, this produced a segfault. Now it returns a usable RemoteSettings
object.
This commit is contained in:
Daniel Drake 2011-08-06 19:59:32 +01:00 committed by Dan Williams
parent f14d8b18ee
commit 87b88fd38c

View file

@ -736,9 +736,6 @@ get_all_cb (DBusGProxy *proxy,
NMRemoteSettings *
nm_remote_settings_new (DBusGConnection *bus)
{
if (bus == NULL)
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
return (NMRemoteSettings *) g_object_new (NM_TYPE_REMOTE_SETTINGS,
NM_REMOTE_SETTINGS_BUS, bus,
NULL);
@ -887,11 +884,15 @@ set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
DBusGConnection *connection;
switch (prop_id) {
case PROP_BUS:
/* Construct only */
priv->bus = dbus_g_connection_ref ((DBusGConnection *) g_value_get_boxed (value));
connection = (DBusGConnection *) g_value_get_boxed (value);
if (!connection)
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
priv->bus = dbus_g_connection_ref (connection);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);