gdbusconnection: Improve docs of message ownership in closures

This introduces no functional changes, but makes it a little clearer how
the ownership of these `GDBusMessage` instances works. The free function
is changed to `g_clear_object()` to avoid the possibility of somehow
using the messages after freeing them.

Basically just some drive-by docs improvements while trying to debug
issue #1264.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1264
This commit is contained in:
Philip Withnall 2023-02-22 02:46:55 +00:00
parent 127c899a2e
commit 90af20d950

View File

@ -3743,7 +3743,7 @@ g_dbus_connection_signal_unsubscribe (GDBusConnection *connection,
typedef struct typedef struct
{ {
SignalSubscriber *subscriber; /* (owned) */ SignalSubscriber *subscriber; /* (owned) */
GDBusMessage *message; GDBusMessage *message; /* (owned) */
GDBusConnection *connection; GDBusConnection *connection;
const gchar *sender; /* (nullable) for peer-to-peer connections */ const gchar *sender; /* (nullable) for peer-to-peer connections */
const gchar *path; const gchar *path;
@ -3807,7 +3807,7 @@ emit_signal_instance_in_idle_cb (gpointer data)
static void static void
signal_instance_free (SignalInstance *signal_instance) signal_instance_free (SignalInstance *signal_instance)
{ {
g_object_unref (signal_instance->message); g_clear_object (&signal_instance->message);
g_object_unref (signal_instance->connection); g_object_unref (signal_instance->connection);
signal_subscriber_unref (signal_instance->subscriber); signal_subscriber_unref (signal_instance->subscriber);
g_free (signal_instance); g_free (signal_instance);
@ -4219,7 +4219,7 @@ has_object_been_unregistered (GDBusConnection *connection,
typedef struct typedef struct
{ {
GDBusConnection *connection; GDBusConnection *connection;
GDBusMessage *message; GDBusMessage *message; /* (owned) */
gpointer user_data; gpointer user_data;
const gchar *property_name; const gchar *property_name;
const GDBusInterfaceVTable *vtable; const GDBusInterfaceVTable *vtable;
@ -4233,7 +4233,7 @@ static void
property_data_free (PropertyData *data) property_data_free (PropertyData *data)
{ {
g_object_unref (data->connection); g_object_unref (data->connection);
g_object_unref (data->message); g_clear_object (&data->message);
g_free (data); g_free (data);
} }
@ -4575,7 +4575,7 @@ handle_getset_property (GDBusConnection *connection,
typedef struct typedef struct
{ {
GDBusConnection *connection; GDBusConnection *connection;
GDBusMessage *message; GDBusMessage *message; /* (owned) */
gpointer user_data; gpointer user_data;
const GDBusInterfaceVTable *vtable; const GDBusInterfaceVTable *vtable;
GDBusInterfaceInfo *interface_info; GDBusInterfaceInfo *interface_info;
@ -4587,7 +4587,7 @@ static void
property_get_all_data_free (PropertyGetAllData *data) property_get_all_data_free (PropertyGetAllData *data)
{ {
g_object_unref (data->connection); g_object_unref (data->connection);
g_object_unref (data->message); g_clear_object (&data->message);
g_free (data); g_free (data);
} }
@ -6815,7 +6815,7 @@ typedef struct
static void static void
subtree_deferred_data_free (SubtreeDeferredData *data) subtree_deferred_data_free (SubtreeDeferredData *data)
{ {
g_object_unref (data->message); g_clear_object (&data->message);
exported_subtree_unref (data->es); exported_subtree_unref (data->es);
g_free (data); g_free (data);
} }