gdbusproxy: only connect to NameOwnerChanged for message buses

Names are a message bus feature, so it does not make sense to connect
to NameOwnerChanged when the underlying connection is not a message
bus.

Moreover, g_dbus_connection_signal_subscribe() will also enforce that
condition. Adding this extra check here is helpful to avoid a critical
warning when using GDBusProxy with peer-to-peer connections.

https://gitlab.gnome.org/GNOME/glib/issues/1620
This commit is contained in:
Cosimo Cecchi 2018-12-20 00:37:11 +00:00
parent 7d02e32644
commit dec0a6874e

View File

@ -1768,7 +1768,8 @@ async_initable_init_first (GAsyncInitable *initable)
(GDestroyNotify) signal_subscription_unref); (GDestroyNotify) signal_subscription_unref);
} }
if (proxy->priv->name != NULL) if (proxy->priv->name != NULL &&
(g_dbus_connection_get_flags (proxy->priv->connection) & G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION))
{ {
proxy->priv->name_owner_changed_subscription_id = proxy->priv->name_owner_changed_subscription_id =
g_dbus_connection_signal_subscribe (proxy->priv->connection, g_dbus_connection_signal_subscribe (proxy->priv->connection,