Use "&s" instead of "s", and free the variant iters after use.
Bug #618663.
const gchar *greeting;
gchar *response;
- g_variant_get (parameters, "(s)", &greeting);
+ g_variant_get (parameters, "(&s)", &greeting);
response = g_strdup_printf ("You said '%s'. KTHXBYE!", greeting);
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(s)", response));
g_error_free (error);
goto out;
}
- g_variant_get (value, "(s)", &greeting_response);
+ g_variant_get (value, "(&s)", &greeting_response);
g_print ("Server said: %s\n", greeting_response);
g_variant_unref (value);
{
AccountsUser *user = ACCOUNTS_USER (proxy);
GVariantIter *iter;
- GVariant *item;
+ const gchar *key;
if (changed_properties != NULL)
{
g_variant_get (changed_properties, "a{sv}", &iter);
- while ((item = g_variant_iter_next_value (iter)) != NULL)
+ while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
{
- const gchar *key;
- g_variant_get (item,
- "{sv}",
- &key,
- NULL);
if (g_strcmp0 (key, "AutomaticLogin") == 0)
g_object_notify (G_OBJECT (user), "automatic-login");
else if (g_strcmp0 (key, "RealName") == 0)
else if (g_strcmp0 (key, "UserName") == 0)
g_object_notify (G_OBJECT (user), "user-name");
}
+ g_variant_iter_free (iter);
}
}
if (value != NULL)
{
g_variant_get (value, "(s)", &ret);
- ret = g_strdup (ret);
g_variant_unref (value);
}
return ret;
if (value != NULL)
{
g_variant_get (value, "(s)", &ret);
- ret = g_strdup (ret);
g_variant_unref (value);
}
return ret;
{
const gchar *greeting;
- g_variant_get (parameters, "(s)", &greeting);
+ g_variant_get (parameters, "(&s)", &greeting);
if (g_strcmp0 (greeting, "Return Unregistered") == 0)
{
g_assert_cmpstr (interface_name, ==, "org.gtk.GDBus.Example.Manager");
g_assert_cmpstr (method_name, ==, "Hello");
- g_variant_get (parameters, "(s)", &greeting);
+ g_variant_get (parameters, "(&s)", &greeting);
response = g_strdup_printf ("Method %s.%s with user_data `%s' on object path %s called with arg '%s'",
interface_name,
const gchar *greeting;
gchar *response;
- g_variant_get (parameters, "(s)", &greeting);
+ g_variant_get (parameters, "(&s)", &greeting);
response = g_strdup_printf ("Method %s.%s with user_data `%s' on object path %s called with arg '%s'",
interface_name,
g_assert_cmpstr (interface_name, ==, "org.gtk.GDBus.Example.Partition");
g_assert_cmpstr (method_name, ==, "Hello");
- g_variant_get (parameters, "(s)", &greeting);
+ g_variant_get (parameters, "(&s)", &greeting);
response = g_strdup_printf ("Method %s.%s with user_data `%s' on object path %s called with arg '%s'",
interface_name,
if (g_variant_n_children (changed_properties) > 0)
{
GVariantIter *iter;
- GVariant *item;
+ const gchar *key;
+ GVariant *value;
g_print (" *** Properties Changed:\n");
g_variant_get (changed_properties,
"a{sv}",
&iter);
- while ((item = g_variant_iter_next_value (iter)))
+ while (g_variant_iter_loop (iter, "{&sv}", &key, &value))
{
- const gchar *key;
- GVariant *value;
gchar *value_str;
- g_variant_get (item,
- "{sv}",
- &key,
- &value);
value_str = g_variant_print (value, TRUE);
g_print (" %s -> %s\n", key, value_str);
g_free (value_str);
}
+ g_variant_iter_free (iter);
}
if (g_strv_length ((GStrv) invalidated_properties) > 0)
{
const gchar *input;
gchar *output;
- g_variant_get (parameters, "(s)", &input);
+ g_variant_get (parameters, "(&s)", &input);
output = g_strdup_printf ("You passed the string `%s'. Jolly good!", input);
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", output));
g_free (output);
GAsyncResult *res,
gpointer user_data)
{
- const gchar *s;
gchar **xml_data = user_data;
GVariant *result;
GError *error;
&error);
g_assert_no_error (error);
g_assert (result != NULL);
- g_variant_get (result, "(s)", &s);
- *xml_data = g_strdup (s);
+ g_variant_get (result, "(s)", xml_data);
g_variant_unref (result);
g_main_loop_quit (loop);
g_assert_no_error (error);
g_assert (value != NULL);
g_assert (g_variant_is_of_type (value, G_VARIANT_TYPE ("(s)")));
- g_variant_get (value, "(s)", &value_str);
+ g_variant_get (value, "(&s)", &value_str);
g_assert_cmpstr (value_str, ==, "You passed the string `winwinwin'. Jolly good!");
g_variant_unref (value);
&error);
g_assert_no_error (error);
g_assert (result != NULL);
- g_variant_get (result, "(s)", &xml_data);
+ g_variant_get (result, "(&s)", &xml_data);
node_info = g_dbus_node_info_new_for_xml (xml_data, &error);
g_assert_no_error (error);
const gchar *greeting;
gchar *response;
- g_variant_get (parameters, "(s)", &greeting);
+ g_variant_get (parameters, "(&s)", &greeting);
response = g_strdup_printf ("You greeted me with '%s'.",
greeting);
gint fd;
GUnixFDList *fd_list;
- g_variant_get (parameters, "(s)", &path);
+ g_variant_get (parameters, "(&s)", &path);
fd_list = g_unix_fd_list_new ();
NULL, /* GCancellable */
&error);
g_assert_no_error (error);
- g_variant_get (result, "(s)", &s);
+ g_variant_get (result, "(&s)", &s);
g_assert_cmpstr (s, ==, "You greeted me with 'Hey Peer!'.");
g_variant_unref (result);
g_assert_cmpint (data.num_method_calls, ==, 1);
NULL, /* GCancellable */
&error);
g_assert_no_error (error);
- g_variant_get (result, "(s)", &s);
+ g_variant_get (result, "(&s)", &s);
g_assert_cmpstr (s, ==, "You greeted me with 'Hey Again Peer!'.");
g_variant_unref (result);
g_assert_cmpint (data.num_method_calls, ==, 4);
g_assert_no_error (error);
g_assert (result != NULL);
g_assert_cmpstr (g_variant_get_type_string (result), ==, "(s)");
- g_variant_get (result, "(s)", &str);
+ g_variant_get (result, "(&s)", &str);
g_assert_cmpstr (str, ==, "You greeted me with 'Hey'. Thanks!");
g_variant_unref (result);