parent
10361fb485
commit
ecd0a7b795
@ -0,0 +1,64 @@
|
||||
From 9723c65d0295baedeb6ee4cb85b35ab51ef22376 Mon Sep 17 00:00:00 2001
|
||||
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
|
||||
Date: Mon, 22 Nov 2021 17:04:36 +0900
|
||||
Subject: [PATCH] GnomeCmdData::save_devices: place GVariantBuilder structure
|
||||
on stack initially
|
||||
|
||||
As written on:
|
||||
https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/glib/glib-GVariant.html#g-variant-builder-new
|
||||
when calling g_variant_builder_init(), GVariantBuilder structure must be placed on stack first
|
||||
and the reference to the memory must be passed to the function, instead of
|
||||
passing nullptr.
|
||||
---
|
||||
src/gnome-cmd-data.cc | 15 ++++++++-------
|
||||
1 file changed, 8 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
|
||||
index 51407cc..b38f96a 100644
|
||||
--- a/src/gnome-cmd-data.cc
|
||||
+++ b/src/gnome-cmd-data.cc
|
||||
@@ -1722,23 +1722,24 @@ void GnomeCmdData::save_devices()
|
||||
devices = gnome_cmd_con_list_get_all_dev (gnome_cmd_data.priv->con_list);
|
||||
if (devices && g_list_length(devices) > 0)
|
||||
{
|
||||
- GVariantBuilder *gVariantBuilder = nullptr;
|
||||
+ GVariantBuilder gVariantBuilder;
|
||||
+ gboolean device_added_p = false;
|
||||
|
||||
for (; devices; devices = devices->next)
|
||||
{
|
||||
auto *device = GNOME_CMD_CON_DEVICE (devices->data);
|
||||
if (device && !gnome_cmd_con_device_get_autovol (device))
|
||||
{
|
||||
- if (!gVariantBuilder)
|
||||
+ if (!device_added_p)
|
||||
{
|
||||
- g_variant_builder_init (gVariantBuilder, G_VARIANT_TYPE_ARRAY);
|
||||
+ g_variant_builder_init (&gVariantBuilder, G_VARIANT_TYPE_ARRAY);
|
||||
}
|
||||
-
|
||||
+ device_added_p = true;
|
||||
gchar *icon_path = g_strdup (gnome_cmd_con_device_get_icon_path (device));
|
||||
if (!icon_path || icon_path[0] == '\0')
|
||||
icon_path = g_strdup ("");
|
||||
|
||||
- g_variant_builder_add (gVariantBuilder, GCMD_SETTINGS_DEVICES_FORMAT_STRING,
|
||||
+ g_variant_builder_add (&gVariantBuilder, GCMD_SETTINGS_DEVICES_FORMAT_STRING,
|
||||
gnome_cmd_con_device_get_alias (device),
|
||||
gnome_cmd_con_device_get_device_fn (device),
|
||||
gnome_cmd_con_device_get_mountp (device),
|
||||
@@ -1747,9 +1748,9 @@ void GnomeCmdData::save_devices()
|
||||
}
|
||||
}
|
||||
|
||||
- if (gVariantBuilder)
|
||||
+ if (device_added_p)
|
||||
{
|
||||
- devicesToStore = g_variant_builder_end (gVariantBuilder);
|
||||
+ devicesToStore = g_variant_builder_end (&gVariantBuilder);
|
||||
g_settings_set_value(options.gcmd_settings->general, GCMD_SETTINGS_DEVICES, devicesToStore);
|
||||
return;
|
||||
}
|
||||
--
|
||||
2.33.1
|
||||
|
Loading…
Reference in new issue