if (client == NULL)
return;
- if (!client->initialized)
- goto out;
-
if (g_strcmp0 (object_path, "/org/freedesktop/DBus") != 0 ||
g_strcmp0 (interface_name, "org.freedesktop.DBus") != 0 ||
g_strcmp0 (sender_name, "org.freedesktop.DBus") != 0)
if (g_strcmp0 (name, client->name) != 0)
goto out;
- if ((old_owner != NULL && strlen (old_owner) > 0) && client->name_owner != NULL)
+ if (old_owner != NULL && strlen (old_owner) > 0)
{
g_free (client->name_owner);
client->name_owner = NULL;
if (new_owner != NULL && strlen (new_owner) > 0)
{
- g_warn_if_fail (client->name_owner == NULL);
g_free (client->name_owner);
client->name_owner = g_strdup (new_owner);
call_appeared_handler (client);
}
+ /* initialized set to TRUE means that signal was delivered and processed.
+ * Now, if we receive a reply to GetNameOwner call, we may just ignore it as it carries the same
+ * information as the current signal, or if something changed in the meantime we will
+ * get next signal very soon.
+ */
+ client->initialized = TRUE;
+
out:
client_unref (client);
}
result = g_dbus_connection_call_finish (client->connection,
res,
NULL);
+ /* In case we already received NameOwnerChanged signal, we don't need to
+ * process GetNameOwner answer, because all the information we needed was already
+ * delivered with the signal and processed by the signal handler.
+ */
+ if (client->initialized)
+ goto out;
+
if (result != NULL)
{
g_variant_get (result, "(&s)", &name_owner);
call_vanished_handler (client);
}
- client->initialized = TRUE;
-
+ out:
if (result != NULL)
g_variant_unref (result);
+
client_unref (client);
}