mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
gdbusobjectmanagerclient: Cancel GetManagedObjects on dispose
Make sure there's no async call lingering when disposing the object. Signed-off-by: Guido Günther <agx@sigxcpu.org>
This commit is contained in:
parent
c548ac0796
commit
693ca5eb01
@ -20,11 +20,13 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gcancellable.h"
|
||||
#include "gdbusobjectmanager.h"
|
||||
#include "gdbusobjectmanagerclient.h"
|
||||
#include "gdbusobject.h"
|
||||
#include "gdbusprivate.h"
|
||||
#include "gioenumtypes.h"
|
||||
#include "gioerror.h"
|
||||
#include "ginitable.h"
|
||||
#include "gasyncresult.h"
|
||||
#include "gasyncinitable.h"
|
||||
@ -144,6 +146,7 @@ struct _GDBusObjectManagerClientPrivate
|
||||
|
||||
gulong name_owner_signal_id;
|
||||
gulong signal_signal_id;
|
||||
GCancellable *cancel;
|
||||
};
|
||||
|
||||
enum
|
||||
@ -191,6 +194,20 @@ static void process_get_all_result (GDBusObjectManagerClient *manager,
|
||||
GVariant *value,
|
||||
const gchar *name_owner);
|
||||
|
||||
static void
|
||||
g_dbus_object_manager_client_dispose (GObject *object)
|
||||
{
|
||||
GDBusObjectManagerClient *manager = G_DBUS_OBJECT_MANAGER_CLIENT (object);
|
||||
|
||||
if (manager->priv->cancel != NULL)
|
||||
{
|
||||
g_cancellable_cancel (manager->priv->cancel);
|
||||
g_clear_object (&manager->priv->cancel);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (g_dbus_object_manager_client_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
g_dbus_object_manager_client_finalize (GObject *object)
|
||||
{
|
||||
@ -327,6 +344,7 @@ g_dbus_object_manager_client_class_init (GDBusObjectManagerClientClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->dispose = g_dbus_object_manager_client_dispose;
|
||||
gobject_class->finalize = g_dbus_object_manager_client_finalize;
|
||||
gobject_class->set_property = g_dbus_object_manager_client_set_property;
|
||||
gobject_class->get_property = g_dbus_object_manager_client_get_property;
|
||||
@ -589,6 +607,7 @@ g_dbus_object_manager_client_init (GDBusObjectManagerClient *manager)
|
||||
g_str_equal,
|
||||
g_free,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
manager->priv->cancel = g_cancellable_new ();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
@ -1285,10 +1304,13 @@ on_get_managed_objects_finish (GObject *source,
|
||||
if (value == NULL)
|
||||
{
|
||||
maybe_unsubscribe_signals (manager);
|
||||
g_warning ("Error calling GetManagedObjects() when name owner %s for name %s came back: %s",
|
||||
new_name_owner,
|
||||
manager->priv->name,
|
||||
error->message);
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
{
|
||||
g_warning ("Error calling GetManagedObjects() when name owner %s for name %s came back: %s",
|
||||
new_name_owner,
|
||||
manager->priv->name,
|
||||
error->message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1373,7 +1395,7 @@ on_notify_g_name_owner (GObject *object,
|
||||
NULL, /* parameters */
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL,
|
||||
manager->priv->cancel,
|
||||
on_get_managed_objects_finish,
|
||||
weak_ref_new (G_OBJECT (manager)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user