mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 06:26:15 +01:00
Merge branch 'th/gdbus-cleanup' into 'master'
[th/gdbus-cleanup] two minor cleanup patches for gdbusconnection.c See merge request GNOME/glib!2025
This commit is contained in:
commit
32fc1e6bbf
@ -1610,7 +1610,6 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection,
|
|||||||
guchar *blob;
|
guchar *blob;
|
||||||
gsize blob_size;
|
gsize blob_size;
|
||||||
guint32 serial_to_use;
|
guint32 serial_to_use;
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
CONNECTION_ENSURE_LOCK (connection);
|
CONNECTION_ENSURE_LOCK (connection);
|
||||||
|
|
||||||
@ -1619,9 +1618,6 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection,
|
|||||||
|
|
||||||
/* TODO: check all necessary headers are present */
|
/* TODO: check all necessary headers are present */
|
||||||
|
|
||||||
ret = FALSE;
|
|
||||||
blob = NULL;
|
|
||||||
|
|
||||||
if (out_serial != NULL)
|
if (out_serial != NULL)
|
||||||
*out_serial = 0;
|
*out_serial = 0;
|
||||||
|
|
||||||
@ -1633,14 +1629,14 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection,
|
|||||||
if (!check_unclosed (connection,
|
if (!check_unclosed (connection,
|
||||||
(flags & SEND_MESSAGE_FLAGS_INITIALIZING) ? MAY_BE_UNINITIALIZED : 0,
|
(flags & SEND_MESSAGE_FLAGS_INITIALIZING) ? MAY_BE_UNINITIALIZED : 0,
|
||||||
error))
|
error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
blob = g_dbus_message_to_blob (message,
|
blob = g_dbus_message_to_blob (message,
|
||||||
&blob_size,
|
&blob_size,
|
||||||
connection->capabilities,
|
connection->capabilities,
|
||||||
error);
|
error);
|
||||||
if (blob == NULL)
|
if (blob == NULL)
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
if (flags & G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL)
|
if (flags & G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL)
|
||||||
serial_to_use = g_dbus_message_get_serial (message);
|
serial_to_use = g_dbus_message_get_serial (message);
|
||||||
@ -1686,18 +1682,13 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection,
|
|||||||
g_dbus_message_set_serial (message, serial_to_use);
|
g_dbus_message_set_serial (message, serial_to_use);
|
||||||
|
|
||||||
g_dbus_message_lock (message);
|
g_dbus_message_lock (message);
|
||||||
|
|
||||||
_g_dbus_worker_send_message (connection->worker,
|
_g_dbus_worker_send_message (connection->worker,
|
||||||
message,
|
message,
|
||||||
(gchar*) blob,
|
(gchar*) blob, /* transfer ownership */
|
||||||
blob_size);
|
blob_size);
|
||||||
blob = NULL; /* since _g_dbus_worker_send_message() steals the blob */
|
|
||||||
|
|
||||||
ret = TRUE;
|
return TRUE;
|
||||||
|
|
||||||
out:
|
|
||||||
g_free (blob);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2202,6 +2193,24 @@ typedef struct
|
|||||||
GMainContext *context;
|
GMainContext *context;
|
||||||
} FilterData;
|
} FilterData;
|
||||||
|
|
||||||
|
static void
|
||||||
|
filter_data_destroy (FilterData *filter, gboolean notify_sync)
|
||||||
|
{
|
||||||
|
if (notify_sync)
|
||||||
|
{
|
||||||
|
if (filter->user_data_free_func != NULL)
|
||||||
|
filter->user_data_free_func (filter->user_data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
call_destroy_notify (filter->context,
|
||||||
|
filter->user_data_free_func,
|
||||||
|
filter->user_data);
|
||||||
|
}
|
||||||
|
g_main_context_unref (filter->context);
|
||||||
|
g_free (filter);
|
||||||
|
}
|
||||||
|
|
||||||
/* requires CONNECTION_LOCK */
|
/* requires CONNECTION_LOCK */
|
||||||
static FilterData **
|
static FilterData **
|
||||||
copy_filter_list (GPtrArray *filters)
|
copy_filter_list (GPtrArray *filters)
|
||||||
@ -2230,13 +2239,7 @@ free_filter_list (FilterData **filters)
|
|||||||
{
|
{
|
||||||
filters[n]->ref_count--;
|
filters[n]->ref_count--;
|
||||||
if (filters[n]->ref_count == 0)
|
if (filters[n]->ref_count == 0)
|
||||||
{
|
filter_data_destroy (filters[n], FALSE);
|
||||||
call_destroy_notify (filters[n]->context,
|
|
||||||
filters[n]->user_data_free_func,
|
|
||||||
filters[n]->user_data);
|
|
||||||
g_main_context_unref (filters[n]->context);
|
|
||||||
g_free (filters[n]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
g_free (filters);
|
g_free (filters);
|
||||||
}
|
}
|
||||||
@ -3179,16 +3182,9 @@ static void
|
|||||||
purge_all_filters (GDBusConnection *connection)
|
purge_all_filters (GDBusConnection *connection)
|
||||||
{
|
{
|
||||||
guint n;
|
guint n;
|
||||||
for (n = 0; n < connection->filters->len; n++)
|
|
||||||
{
|
|
||||||
FilterData *data = connection->filters->pdata[n];
|
|
||||||
|
|
||||||
call_destroy_notify (data->context,
|
for (n = 0; n < connection->filters->len; n++)
|
||||||
data->user_data_free_func,
|
filter_data_destroy (connection->filters->pdata[n], FALSE);
|
||||||
data->user_data);
|
|
||||||
g_main_context_unref (data->context);
|
|
||||||
g_free (data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3238,12 +3234,7 @@ g_dbus_connection_remove_filter (GDBusConnection *connection,
|
|||||||
|
|
||||||
/* do free without holding lock */
|
/* do free without holding lock */
|
||||||
if (to_destroy != NULL)
|
if (to_destroy != NULL)
|
||||||
{
|
filter_data_destroy (to_destroy, TRUE);
|
||||||
if (to_destroy->user_data_free_func != NULL)
|
|
||||||
to_destroy->user_data_free_func (to_destroy->user_data);
|
|
||||||
g_main_context_unref (to_destroy->context);
|
|
||||||
g_free (to_destroy);
|
|
||||||
}
|
|
||||||
else if (!found)
|
else if (!found)
|
||||||
{
|
{
|
||||||
g_warning ("g_dbus_connection_remove_filter: No filter found for filter_id %d", filter_id);
|
g_warning ("g_dbus_connection_remove_filter: No filter found for filter_id %d", filter_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user