[gnome-commander/gcmd-1-10] Store the default value in gsetting's devices if number of devices is 0
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/gcmd-1-10] Store the default value in gsetting's devices if number of devices is 0
- Date: Wed, 17 Jun 2020 20:38:34 +0000 (UTC)
commit 7533cf959078052ac0ebab77a61fc85ab928b253
Author: Uwe Scholz <u scholz83 gmx de>
Date: Wed Jun 17 22:36:06 2020 +0200
Store the default value in gsetting's devices if number of devices is 0
src/gnome-cmd-data.cc | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index df831b28..af73f583 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -1705,21 +1705,25 @@ void GnomeCmdData::save_devices()
GList *devices;
devices = gnome_cmd_con_list_get_all_dev (gnome_cmd_data.priv->con_list);
- if (devices)
+ if (devices && g_list_length(devices) > 0)
{
- GVariantBuilder gVariantBuilder;
- g_variant_builder_init (&gVariantBuilder, G_VARIANT_TYPE_ARRAY);
+ GVariantBuilder *gVariantBuilder = nullptr;
for (; devices; devices = devices->next)
{
auto *device = GNOME_CMD_CON_DEVICE (devices->data);
if (device && !gnome_cmd_con_device_get_autovol (device))
{
+ if (!gVariantBuilder)
+ {
+ g_variant_builder_init (gVariantBuilder, G_VARIANT_TYPE_ARRAY);
+ }
+
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),
@@ -1727,15 +1731,17 @@ void GnomeCmdData::save_devices()
g_free (icon_path);
}
}
- devicesToStore = g_variant_builder_end (&gVariantBuilder);
- g_settings_set_value(options.gcmd_settings->general, GCMD_SETTINGS_DEVICES, devicesToStore);
- }
- else
- {
- devicesToStore = g_settings_get_default_value(options.gcmd_settings->general,
- GCMD_SETTINGS_DEVICES);
- g_settings_set_value(options.gcmd_settings->general, GCMD_SETTINGS_DEVICES, devicesToStore);
+
+ if (gVariantBuilder)
+ {
+ devicesToStore = g_variant_builder_end (gVariantBuilder);
+ g_settings_set_value(options.gcmd_settings->general, GCMD_SETTINGS_DEVICES, devicesToStore);
+ return;
+ }
}
+
+ devicesToStore = g_settings_get_default_value(options.gcmd_settings->general, GCMD_SETTINGS_DEVICES);
+ g_settings_set_value(options.gcmd_settings->general, GCMD_SETTINGS_DEVICES, devicesToStore);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]