gio: use g_variant_builder_init_static()

All uses of g_variant_builder_init() in gio are safe to translate to the
new g_variant_builder_init_static() alternative as the type will outlive
the call to g_variant_builder_end() (or is already static in nature).
This commit is contained in:
Christian Hergert 2024-09-25 11:09:07 -07:00 committed by Philip Withnall
parent bfac590364
commit 0f95b18a7b
28 changed files with 85 additions and 85 deletions

View File

@ -51,7 +51,7 @@ g_action_group_describe_action (GActionGroup *action_group,
gboolean enabled;
GVariant *state;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(bgav)"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("(bgav)"));
enabled = g_action_group_get_action_enabled (action_group, name);
g_variant_builder_add (&builder, "b", enabled);
@ -146,10 +146,10 @@ g_action_group_exporter_dispatch_events (gpointer user_data)
gpointer value;
gpointer key;
g_variant_builder_init (&removes, G_VARIANT_TYPE_STRING_ARRAY);
g_variant_builder_init (&enabled_changes, G_VARIANT_TYPE ("a{sb}"));
g_variant_builder_init (&state_changes, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init (&adds, G_VARIANT_TYPE ("a{s(bgav)}"));
g_variant_builder_init_static (&removes, G_VARIANT_TYPE_STRING_ARRAY);
g_variant_builder_init_static (&enabled_changes, G_VARIANT_TYPE ("a{sb}"));
g_variant_builder_init_static (&state_changes, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&adds, G_VARIANT_TYPE ("a{s(bgav)}"));
g_hash_table_iter_init (&iter, exporter->pending_changes);
while (g_hash_table_iter_next (&iter, &key, &value))
@ -410,7 +410,7 @@ org_gtk_Actions_method_call (GDBusConnection *connection,
gint i;
list = g_action_group_list_actions (exporter->action_group);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{s(bgav)}"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("a{s(bgav)}"));
for (i = 0; list[i]; i++)
{
const gchar *name = list[i];

View File

@ -299,7 +299,7 @@ app_get_platform_data (void)
GVariantBuilder builder;
const gchar *startup_id;
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_VARDICT);
if ((startup_id = g_getenv ("DESKTOP_STARTUP_ID")))
g_variant_builder_add (&builder, "{sv}", "desktop-startup-id", g_variant_new_string (startup_id));
@ -334,7 +334,7 @@ app_action (gchar **args)
return 1;
}
g_variant_builder_init (&params, G_VARIANT_TYPE ("av"));
g_variant_builder_init_static (&params, G_VARIANT_TYPE ("av"));
if (args[2])
{
@ -387,7 +387,7 @@ app_launch (gchar **args)
if (args[1] == NULL)
return app_activate (args[0]);
g_variant_builder_init (&files, G_VARIANT_TYPE_STRING_ARRAY);
g_variant_builder_init_static (&files, G_VARIANT_TYPE_STRING_ARRAY);
for (i = 1; args[i]; i++)
{

View File

@ -156,7 +156,7 @@ send_property_change (GApplicationImpl *impl)
{
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_add (&builder,
"{sv}",
"Busy", g_variant_new_boolean (impl->busy));
@ -311,7 +311,7 @@ g_application_impl_method_call (GDBusConnection *connection,
GVariant *value = NULL;
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_TUPLE);
while (g_variant_iter_loop (iter, "v", &value))
{
@ -736,7 +736,7 @@ g_application_impl_open (GApplicationImpl *impl,
GVariantBuilder builder;
gint i;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(assa{sv})"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("(assa{sv})"));
g_variant_builder_open (&builder, G_VARIANT_TYPE_STRING_ARRAY);
for (i = 0; i < n_files; i++)
{

View File

@ -802,7 +802,7 @@ handle_emit (gint *argc,
}
/* Read parameters */
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_TUPLE);
skip_dashes = TRUE;
parm = 0;
for (n = 1; n < (guint) *argc; n++)
@ -1114,7 +1114,7 @@ handle_call (gint *argc,
}
/* Read parameters */
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_TUPLE);
skip_dashes = TRUE;
parm = 0;
for (n = 1; n < (guint) *argc; n++)

View File

@ -376,7 +376,7 @@ g_dbus_action_group_activate_action_full (GRemoteActionGroup *remote,
GDBusActionGroup *group = G_DBUS_ACTION_GROUP (remote);
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("av"));
if (parameter)
g_variant_builder_add (&builder, "v", parameter);

View File

@ -5087,7 +5087,7 @@ invoke_get_all_properties_in_idle_cb (gpointer _data)
* We could fail the whole call if just a single get_property() call
* returns an error. We need clarification in the D-Bus spec about this.
*/
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(a{sv})"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("(a{sv})"));
g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}"));
for (n = 0; data->interface_info->properties != NULL && data->interface_info->properties[n] != NULL; n++)
{

View File

@ -1982,7 +1982,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
goffset offset;
goffset target;
g_variant_builder_init (&builder, type);
g_variant_builder_init_static (&builder, type);
if (array_len == 0)
{
@ -2091,7 +2091,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
const GVariantType *element_type;
GVariantBuilder builder;
g_variant_builder_init (&builder, type);
g_variant_builder_init_static (&builder, type);
element_type = g_variant_type_first (type);
if (!element_type)
{
@ -3028,7 +3028,7 @@ g_dbus_message_to_blob (GDBusMessage *message,
goto out;
}
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{yv}"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("a{yv}"));
g_hash_table_iter_init (&hash_iter, message->headers);
while (g_hash_table_iter_next (&hash_iter, &key, (gpointer) &header_value))
{

View File

@ -869,7 +869,7 @@ manager_method_call (GDBusConnection *connection,
if (g_strcmp0 (method_name, "GetManagedObjects") == 0)
{
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("a{oa{sa{sv}}}"));
g_variant_builder_init_static (&array_builder, G_VARIANT_TYPE ("a{oa{sa{sv}}}"));
g_hash_table_iter_init (&object_iter, manager->priv->map_object_path_to_data);
while (g_hash_table_iter_next (&object_iter, NULL, (gpointer) &data))
{
@ -878,7 +878,7 @@ manager_method_call (GDBusConnection *connection,
GDBusInterfaceSkeleton *iface;
const gchar *iter_object_path;
g_variant_builder_init (&interfaces_builder, G_VARIANT_TYPE ("a{sa{sv}}"));
g_variant_builder_init_static (&interfaces_builder, G_VARIANT_TYPE ("a{sa{sv}}"));
g_hash_table_iter_init (&interface_iter, data->map_iface_name_to_iface);
while (g_hash_table_iter_next (&interface_iter, NULL, (gpointer) &iface))
{
@ -945,7 +945,7 @@ g_dbus_object_manager_server_emit_interfaces_added (GDBusObjectManagerServer *ma
if (data->manager->priv->connection == NULL)
goto out;
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("a{sa{sv}}"));
g_variant_builder_init_static (&array_builder, G_VARIANT_TYPE ("a{sa{sv}}"));
for (n = 0; interfaces[n] != NULL; n++)
{
GDBusInterfaceSkeleton *iface;
@ -991,7 +991,7 @@ g_dbus_object_manager_server_emit_interfaces_removed (GDBusObjectManagerServer *
if (data->manager->priv->connection == NULL)
goto out;
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("as"));
g_variant_builder_init_static (&array_builder, G_VARIANT_TYPE ("as"));
for (n = 0; interfaces[n] != NULL; n++)
g_variant_builder_add (&array_builder, "s", interfaces[n]);

View File

@ -954,7 +954,7 @@ invalidated_property_get_cb (GDBusConnection *connection,
g_variant_get (value, "(v)", &unpacked_value);
/* synthesize the a{sv} in the PropertiesChanged signal */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder, "{sv}", data->prop_name, unpacked_value);
G_LOCK (properties_lock);
@ -1264,7 +1264,7 @@ on_name_owner_changed (GDBusConnection *connection,
const gchar *key;
/* Build changed_properties (always empty) and invalidated_properties ... */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("a{sv}"));
invalidated_properties = g_ptr_array_new_with_free_func (g_free);
g_hash_table_iter_init (&iter, proxy->priv->properties);

View File

@ -235,7 +235,7 @@ set_debug_enabled (GDebugControllerDBus *self,
/* Notify internally and externally of the property change. */
g_object_notify (G_OBJECT (self), "debug-enabled");
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder, "{sv}", "DebugEnabled", g_variant_new_boolean (priv->debug_enabled));
g_dbus_connection_emit_signal (priv->connection,

View File

@ -2809,11 +2809,11 @@ notify_desktop_launch (GDBusConnection *session_bus,
if (session_bus == NULL)
return;
g_variant_builder_init (&uri_variant, G_VARIANT_TYPE ("as"));
g_variant_builder_init_static (&uri_variant, G_VARIANT_TYPE ("as"));
for (iter = uris; iter; iter = iter->next)
g_variant_builder_add (&uri_variant, "s", iter->data);
g_variant_builder_init (&extras_variant, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&extras_variant, G_VARIANT_TYPE ("a{sv}"));
if (sn_id != NULL && g_utf8_validate (sn_id, -1, NULL))
g_variant_builder_add (&extras_variant, "{sv}",
"startup-id",
@ -2866,7 +2866,7 @@ emit_launch_started (GAppLaunchContext *context,
if (startup_id)
{
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_add (&builder, "{sv}",
"startup-notification-id",
g_variant_new_string (startup_id));
@ -3070,7 +3070,7 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo *info,
GVariantBuilder builder;
GVariant *platform_data;
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_add (&builder, "{sv}", "pid", g_variant_new_int32 (pid));
if (sn_id)
g_variant_builder_add (&builder, "{sv}", "startup-notification-id", g_variant_new_string (sn_id));
@ -3128,7 +3128,7 @@ g_desktop_app_info_make_platform_data (GDesktopAppInfo *info,
{
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_VARDICT);
if (launch_context)
{
@ -3190,7 +3190,7 @@ launch_uris_with_dbus_signal_cb (GObject *object,
{
GVariant *platform_data;
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_ARRAY);
/* the docs guarantee `pid` will be set, but we cant
* easily know it for a D-Bus process, so set it to zero */
g_variant_builder_add (&builder, "{sv}", "pid", g_variant_new_int32 (0));
@ -3231,7 +3231,7 @@ launch_uris_with_dbus (GDesktopAppInfo *info,
gchar *object_path;
LaunchUrisWithDBusData *data;
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_TUPLE);
if (uris)
{

View File

@ -143,7 +143,7 @@ g_document_portal_add_documents (GList *uris,
length = g_list_length (uris);
as_is = g_new0 (gboolean, length);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("ah"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("ah"));
fd_list = g_unix_fd_list_new ();
for (l = uris, i = 0; l; l = l->next, i++)

View File

@ -424,7 +424,7 @@ g_emblemed_icon_serialize (GIcon *icon)
if (!icon_data)
return NULL;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(va(va{sv}))"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("(va(va{sv}))"));
g_variant_builder_add (&builder, "v", icon_data);
g_variant_unref (icon_data);

View File

@ -292,7 +292,7 @@ call_notify (GDBusConnection *con,
const gchar *body;
guchar urgency;
g_variant_builder_init (&action_builder, G_VARIANT_TYPE_STRING_ARRAY);
g_variant_builder_init_static (&action_builder, G_VARIANT_TYPE_STRING_ARRAY);
if (g_notification_get_default_action (notification, NULL, NULL))
{
g_variant_builder_add (&action_builder, "s", "default");
@ -329,7 +329,7 @@ call_notify (GDBusConnection *con,
g_variant_unref (target);
}
g_variant_builder_init (&hints_builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&hints_builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&hints_builder, "{sv}", "desktop-entry",
g_variant_new_string (g_application_get_application_id (app)));
urgency = urgency_from_priority (g_notification_get_priority (notification));

View File

@ -606,7 +606,7 @@ parse_resource_file (const gchar *filename,
g_free (mykey);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(uuay)"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("(uuay)"));
g_variant_builder_add (&builder, "u", data->size); /* Size */
g_variant_builder_add (&builder, "u", data->flags); /* Flags */

View File

@ -653,7 +653,7 @@ key_state_serialise (KeyState *state)
checked = key_state_check (state, NULL);
g_assert (checked);
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_TUPLE);
/* default value */
g_variant_builder_add_value (&builder, state->default_value);

View File

@ -197,7 +197,7 @@ g_menu_exporter_menu_describe_item (GMenuExporterMenu *menu,
const char *name;
GVariant *value;
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_VARDICT);
attr_iter = g_menu_model_iterate_item_attributes (menu->model, position);
while (g_menu_attribute_iter_get_next (attr_iter, &name, &value))
@ -221,7 +221,7 @@ g_menu_exporter_menu_list (GMenuExporterMenu *menu)
GVariantBuilder builder;
gint i, n;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("aa{sv}"));
n = g_sequence_get_length (menu->item_links);
for (i = 0; i < n; i++)
@ -266,7 +266,7 @@ g_menu_exporter_menu_items_changed (GMenuModel *model,
{
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(uuuuaa{sv})"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("(uuuuaa{sv})"));
g_variant_builder_add (&builder, "u", g_menu_exporter_group_get_id (menu->group));
g_variant_builder_add (&builder, "u", menu->id);
g_variant_builder_add (&builder, "u", position);
@ -607,7 +607,7 @@ g_menu_exporter_subscribe (GMenuExporter *exporter,
g_menu_exporter_remote_new (exporter, 0);
}
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(a(uuaa{sv}))"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("(a(uuaa{sv}))"));
g_variant_builder_open (&builder, G_VARIANT_TYPE ("a(uuaa{sv})"));
@ -656,7 +656,7 @@ g_menu_exporter_report (GMenuExporter *exporter,
{
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_open (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_add_value (&builder, report);
g_variant_builder_close (&builder);

View File

@ -343,7 +343,7 @@ g_nextstep_settings_backend_get_g_variant (id object,
value_type = g_variant_type_value (g_variant_type_element (type));
g_variant_builder_init (&builder, type);
g_variant_builder_init_static (&builder, type);
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
for(key in object)
@ -384,7 +384,7 @@ g_nextstep_settings_backend_get_g_variant (id object,
id value;
value_type = g_variant_type_element (type);
g_variant_builder_init (&builder, type);
g_variant_builder_init_static (&builder, type);
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
for(value in object)

View File

@ -767,7 +767,7 @@ g_notification_serialize_button (Button *button)
{
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder, "{sv}", "label", g_variant_new_string (button->label));
g_variant_builder_add (&builder, "{sv}", "action", g_variant_new_string (button->action_name));
@ -806,7 +806,7 @@ g_notification_serialize (GNotification *notification)
{
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("a{sv}"));
if (notification->title)
g_variant_builder_add (&builder, "{sv}", "title", g_variant_new_string (notification->title));
@ -842,7 +842,7 @@ g_notification_serialize (GNotification *notification)
GVariantBuilder actions_builder;
guint i;
g_variant_builder_init (&actions_builder, G_VARIANT_TYPE ("aa{sv}"));
g_variant_builder_init_static (&actions_builder, G_VARIANT_TYPE ("aa{sv}"));
for (i = 0; i < notification->buttons->len; i++)
{

View File

@ -95,7 +95,7 @@ g_openuri_portal_open_file (GFile *file,
return FALSE;
}
g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_init_static (&opt_builder, G_VARIANT_TYPE_VARDICT);
if (startup_id)
g_variant_builder_add (&opt_builder, "{sv}",
@ -306,7 +306,7 @@ g_openuri_portal_open_file_async (GFile *file,
NULL);
g_object_set_data (G_OBJECT (task), "signal-id", GINT_TO_POINTER (signal_id));
g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_init_static (&opt_builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add (&opt_builder, "{sv}", "handle_token", g_variant_new_string (token));
g_free (token);

View File

@ -410,7 +410,7 @@ g_settings_set_mapping (const GValue *value,
fclass = g_type_class_peek (G_VALUE_TYPE (value));
flags = g_value_get_flags (value);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("as"));
while (flags)
{
flagsval = g_flags_get_first_value (fclass, flags);

View File

@ -1381,7 +1381,7 @@ g_settings_schema_key_range_fixup (GSettingsSchemaKey *key,
GVariant *child;
g_variant_iter_init (&iter, value);
g_variant_builder_init (&builder, g_variant_get_type (value));
g_variant_builder_init_static (&builder, g_variant_get_type (value));
while ((child = g_variant_iter_next_value (&iter)))
{
@ -1574,7 +1574,7 @@ g_settings_schema_key_from_flags (GSettingsSchemaKey *key,
GVariantBuilder builder;
gint i;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("as"));
for (i = 0; i < 32; i++)
if (value & (1u << i))

View File

@ -4790,7 +4790,7 @@ make_platform_data (GPid pid)
{
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_ARRAY);
/* pid handles are never bigger than 2^24 as per
* https://docs.microsoft.com/en-us/windows/win32/sysinfo/kernel-objects,
* so truncating to `int32` is valid.

View File

@ -272,7 +272,7 @@ strinfo_enumerate (const guint32 *strinfo,
ptr += 4;
g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
g_variant_builder_init_static (&builder, G_VARIANT_TYPE_STRING_ARRAY);
while (ptr < end)
{

View File

@ -1368,7 +1368,7 @@ test_dbus_activate (void)
g_ptr_array_add (messages, g_steal_pointer (&message));
/* With some platform data */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder, "{sv}", "cwd", g_variant_new_bytestring ("/home/henry"));
message = g_dbus_message_new_method_call ("org.gtk.TestApplication.Activate",
@ -1446,7 +1446,7 @@ test_dbus_open (void)
messages = g_ptr_array_new_with_free_func (g_object_unref);
/* Via org.gtk.Application */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("as"));
g_variant_builder_add (&builder, "s", "file:///home/henry/test");
message = g_dbus_message_new_method_call ("org.gtk.TestApplication.Open",
@ -1457,7 +1457,7 @@ test_dbus_open (void)
g_ptr_array_add (messages, g_steal_pointer (&message));
/* Via org.freedesktop.Application (which has no hint parameter) */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("as"));
g_variant_builder_add (&builder, "s", "file:///home/henry/test");
message = g_dbus_message_new_method_call ("org.gtk.TestApplication.Open",
@ -1468,11 +1468,11 @@ test_dbus_open (void)
g_ptr_array_add (messages, g_steal_pointer (&message));
/* With some platform data and more than one file */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("as"));
g_variant_builder_add (&builder, "s", "file:///home/henry/test");
g_variant_builder_add (&builder, "s", "file:///home/henry/test2");
g_variant_builder_init (&builder2, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&builder2, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder2, "{sv}", "cwd", g_variant_new_bytestring ("/home/henry"));
message = g_dbus_message_new_method_call ("org.gtk.TestApplication.Open",
@ -1550,7 +1550,7 @@ test_dbus_command_line (void)
messages = g_ptr_array_new_with_free_func (g_object_unref);
/* Via org.gtk.Application */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("aay"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("aay"));
g_variant_builder_add (&builder, "^ay", "test-program");
g_variant_builder_add (&builder, "^ay", "--open");
g_variant_builder_add (&builder, "^ay", "/path/to/something");
@ -1565,12 +1565,12 @@ test_dbus_command_line (void)
g_ptr_array_add (messages, g_steal_pointer (&message));
/* With platform data */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("aay"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("aay"));
g_variant_builder_add (&builder, "^ay", "test-program");
g_variant_builder_add (&builder, "^ay", "--open");
g_variant_builder_add (&builder, "^ay", "/path/to/something");
g_variant_builder_init (&builder2, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&builder2, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder2, "{sv}", "cwd", g_variant_new_bytestring ("/home"));
g_variant_builder_add_parsed (&builder2, "{'environ', <@aay [ b'HOME=/home/bloop', b'PATH=/blah']>}");
g_variant_builder_add_parsed (&builder2, "{'options', <{'a': <@u 32>, 'b': <'bloop'>}>}");
@ -1585,12 +1585,12 @@ test_dbus_command_line (void)
g_ptr_array_add (messages, g_steal_pointer (&message));
/* With invalid typed platform data */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("aay"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("aay"));
g_variant_builder_add (&builder, "^ay", "test-program");
g_variant_builder_add (&builder, "^ay", "--open");
g_variant_builder_add (&builder, "^ay", "/path/to/something");
g_variant_builder_init (&builder2, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&builder2, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder2, "{sv}", "cwd", g_variant_new_string ("/home should be a bytestring"));
g_variant_builder_add_parsed (&builder2, "{'environ', <['HOME=should be a bytestring', 'PATH=this also']>}");
g_variant_builder_add_parsed (&builder2, "{'options', <['should be a', 'dict']>}");
@ -1673,7 +1673,7 @@ test_dbus_command_line_done (void)
g_test_summary ("Test that GDBusCommandLine.done() works");
g_variant_builder_init (&builder, G_VARIANT_TYPE ("aay"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("aay"));
g_variant_builder_add (&builder, "^ay", "test-program");
g_variant_builder_add (&builder, "^ay", "/path/to/something");
@ -1748,7 +1748,7 @@ test_dbus_activate_action (void)
messages[0].n_expected_activations = 1;
/* Action with parameter */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_add (&builder, "v", g_variant_new_string ("spanish"));
messages[1].message = g_dbus_message_new_method_call ("org.gtk.TestApplication.ActivateAction",
@ -1759,7 +1759,7 @@ test_dbus_activate_action (void)
messages[1].n_expected_activations = 1;
/* Action with unexpected parameter */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_add (&builder, "v", g_variant_new_string ("should not be passed"));
messages[2].message = g_dbus_message_new_method_call ("org.gtk.TestApplication.ActivateAction",
@ -1778,7 +1778,7 @@ test_dbus_activate_action (void)
messages[3].n_expected_activations = 0;
/* Action with wrong parameter type */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_add (&builder, "v", g_variant_new_uint32 (42));
messages[4].message = g_dbus_message_new_method_call ("org.gtk.TestApplication.ActivateAction",
@ -1797,7 +1797,7 @@ test_dbus_activate_action (void)
messages[5].n_expected_activations = 0;
/* Action with tuple as parameter given as two items to the interface */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_add (&builder, "v", g_variant_new_string ("first"));
g_variant_builder_add (&builder, "v", g_variant_new_string ("second"));
@ -1810,7 +1810,7 @@ test_dbus_activate_action (void)
messages[6].n_expected_activations = 1;
/* Action with tuple as parameter given as two items to the interface but with a wrong type */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_add (&builder, "v", g_variant_new_string ("first"));
g_variant_builder_add (&builder, "v", g_variant_new_uint32 (42));
@ -1822,7 +1822,7 @@ test_dbus_activate_action (void)
messages[7].n_expected_activations = 0;
/* Action with tuple as parameter given as a single item to the interface */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_add (&builder, "v", g_variant_new ("(ss)", "first", "second"));
messages[8].message = g_dbus_message_new_method_call ("org.gtk.TestApplication.ActivateAction",
@ -1833,7 +1833,7 @@ test_dbus_activate_action (void)
messages[8].n_expected_activations = 1;
/* Action with tuple as parameter given as a single item to the interface but with additional items */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_add (&builder, "v", g_variant_new ("(ss)", "first", "second"));
g_variant_builder_add (&builder, "v", g_variant_new_uint32 (42));
g_variant_builder_add (&builder, "v", g_variant_new_uint32 (42));
@ -1846,7 +1846,7 @@ test_dbus_activate_action (void)
messages[9].n_expected_activations = 0;
/* Action with tuple with single item as parameter */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_add (&builder, "v", g_variant_new ("(s)", "first"));
messages[10].message = g_dbus_message_new_method_call ("org.gtk.TestApplication.ActivateAction",
@ -1857,7 +1857,7 @@ test_dbus_activate_action (void)
messages[10].n_expected_activations = 1;
/* Action with tuple with single item as parameter with additional items */
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("av"));
g_variant_builder_add (&builder, "v", g_variant_new ("(s)", "first"));
g_variant_builder_add (&builder, "v", g_variant_new_uint32 (42));
g_variant_builder_add (&builder, "v", g_variant_new_uint32 (43));

View File

@ -129,7 +129,7 @@ mock_interface_get_properties (GDBusInterfaceSkeleton *interface)
info = g_dbus_interface_skeleton_get_info (interface);
vtable = g_dbus_interface_skeleton_get_vtable (interface);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("a{sv}"));
for (n = 0; info->properties[n] != NULL; n++)
{
if (info->properties[n]->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)

View File

@ -1262,7 +1262,7 @@ test_message_serialize_double_array (void)
g_test_bug ("https://bugzilla.gnome.org/show_bug.cgi?id=732754");
g_variant_builder_init (&builder, G_VARIANT_TYPE ("ad"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("ad"));
g_variant_builder_add (&builder, "d", (gdouble)0.0);
g_variant_builder_add (&builder, "d", (gdouble)8.0);
g_variant_builder_add (&builder, "d", (gdouble)22.0);
@ -1639,7 +1639,7 @@ test_message_parse_truncated (void)
g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/2528");
message = g_dbus_message_new ();
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(asbynqiuxtd)"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("(asbynqiuxtd)"));
g_variant_builder_open (&builder, G_VARIANT_TYPE ("as"));
g_variant_builder_add (&builder, "s", "fourtytwo");
g_variant_builder_close (&builder);
@ -1747,7 +1747,7 @@ test_message_serialize_empty_structure (void)
g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/2557");
message = g_dbus_message_new ();
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(a())"));
g_variant_builder_init_static (&builder, G_VARIANT_TYPE ("(a())"));
g_variant_builder_open (&builder, G_VARIANT_TYPE ("a()"));
g_variant_builder_add (&builder, "()");
g_variant_builder_close (&builder);

View File

@ -327,7 +327,7 @@ handle_method_call (GDBusConnection *connection,
gsize i, j;
GVariantBuilder ret;
g_variant_builder_init (&ret, G_VARIANT_TYPE ("(ayabanaqaiauaxatad)"));
g_variant_builder_init_static (&ret, G_VARIANT_TYPE ("(ayabanaqaiauaxatad)"));
v = g_variant_get_child_value (parameters, 0);
bytes = g_variant_get_fixed_array (v, &n_elts, 1);
@ -423,7 +423,7 @@ handle_method_call (GDBusConnection *connection,
const gchar *s;
gint i;
g_variant_builder_init (&ret, G_VARIANT_TYPE ("(asaoag)"));
g_variant_builder_init_static (&ret, G_VARIANT_TYPE ("(asaoag)"));
g_variant_get (parameters, "(asaoag)", &iter1, &iter2, &iter3);
g_variant_builder_open (&ret, G_VARIANT_TYPE ("as"));
@ -479,7 +479,7 @@ handle_method_call (GDBusConnection *connection,
gdouble d1, d2;
gchar *s1, *s2;
g_variant_builder_init (&ret, G_VARIANT_TYPE ("(a{yy}a{bb}a{nn}a{qq}a{ii}a{uu}a{xx}a{tt}a{dd}a{ss}a{oo}a{gg})"));
g_variant_builder_init_static (&ret, G_VARIANT_TYPE ("(a{yy}a{bb}a{nn}a{qq}a{ii}a{uu}a{xx}a{tt}a{dd}a{ss}a{oo}a{gg})"));
g_variant_builder_open (&ret, G_VARIANT_TYPE ("a{yy}"));
v = g_variant_get_child_value (parameters, 0);
@ -617,7 +617,7 @@ handle_method_call (GDBusConnection *connection,
desc_ret = g_strconcat (desc, "... in bed!", NULL);
g_variant_builder_init (&ret1, G_VARIANT_TYPE ("ay"));
g_variant_builder_init_static (&ret1, G_VARIANT_TYPE ("ay"));
iter = g_variant_iter_copy (iter1);
while (g_variant_iter_loop (iter1, "y", &v))
g_variant_builder_add (&ret1, "y", v);
@ -626,7 +626,7 @@ handle_method_call (GDBusConnection *connection,
g_variant_iter_free (iter);
g_variant_iter_free (iter1);
g_variant_builder_init (&ret2, G_VARIANT_TYPE ("a{ss}"));
g_variant_builder_init_static (&ret2, G_VARIANT_TYPE ("a{ss}"));
while (g_variant_iter_loop (iter1, "ss", &s1, &s2))
{
gchar *tmp;