aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-08-29 08:20:51 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-08-29 08:22:09 +0200
commitbea8d13227ec01ba325f0bab512b0c16b1fea976 (patch)
tree409b08c85016e8e9a4c40e36a1e5f98188d88692
parentecebeace0ea28f243045bdee1002530028846fe8 (diff)
downloadxK-bea8d13227ec01ba325f0bab512b0c16b1fea976.tar.gz
xK-bea8d13227ec01ba325f0bab512b0c16b1fea976.tar.xz
xK-bea8d13227ec01ba325f0bab512b0c16b1fea976.zip
xC: don't autosave when nothing changed
-rw-r--r--xC.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/xC.c b/xC.c
index 84c5532..50ddbcb 100644
--- a/xC.c
+++ b/xC.c
@@ -11361,7 +11361,7 @@ handle_command_set_modify
return result;
}
-static void
+static bool
handle_command_set_assign_item (struct app_context *ctx,
char *key, struct config_item *new_, bool add, bool remove)
{
@@ -11384,14 +11384,14 @@ handle_command_set_assign_item (struct app_context *ctx,
log_global_error (ctx,
"Failed to set option \"#s\": #s", key, e->message);
error_free (e);
+ return false;
}
- else
- {
- struct strv tmp = strv_make ();
- dump_matching_options (ctx->config.root, key, &tmp);
- log_global_status (ctx, "Option changed: #s", tmp.vector[0]);
- strv_free (&tmp);
- }
+
+ struct strv tmp = strv_make ();
+ dump_matching_options (ctx->config.root, key, &tmp);
+ log_global_status (ctx, "Option changed: #s", tmp.vector[0]);
+ strv_free (&tmp);
+ return true;
}
static bool
@@ -11427,15 +11427,18 @@ handle_command_set_assign
config_item_destroy (new_);
return true;
}
+
+ bool changed = false;
for (size_t i = 0; i < all->len; i++)
{
char *key = cstr_cut_until (all->vector[i], " ");
- handle_command_set_assign_item (ctx, key, new_, add, remove);
+ if (handle_command_set_assign_item (ctx, key, new_, add, remove))
+ changed = true;
free (key);
}
config_item_destroy (new_);
- if (get_config_boolean (ctx->config.root, "general.autosave"))
+ if (changed && get_config_boolean (ctx->config.root, "general.autosave"))
save_configuration (ctx);
return true;
}