From 74dec190871344eed8d26ae3cfbfa53799b5315a Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 4 Oct 2009 14:05:11 +0000 Subject: [PATCH] Do not save twice the same value --- src/run.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/run.c b/src/run.c index d0c4d1c..c9733ab 100644 --- a/src/run.c +++ b/src/run.c @@ -154,7 +154,7 @@ static GtkWidget * _new_entry(Config * config) { snprintf(buf, sizeof(buf), "%s%d", "command", i); if((q = config_get(config, "", buf)) == NULL) - break; + continue; gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, q, -1); } @@ -242,7 +242,6 @@ static void _on_run_choose_activate(GtkWidget * widget, gint arg1, /* on_run_execute */ -/* static void _execute_parent(GtkWidget * window, pid_t pid); */ static gboolean _execute_idle(gpointer data); static void _idle_save_config(Run * run); @@ -322,6 +321,15 @@ static void _idle_save_config(Run * run) #endif p = gtk_entry_get_text(GTK_ENTRY(run->entry)); for(i = 0; i < 100; i++) + { + snprintf(buf, sizeof(buf), "%s%d", "command", i); + q = config_get(run->config, "", buf); + if(q == NULL || strcmp(p, q) != 0) + continue; + free(filename); /* the command is already known */ + return; + } + for(i = 0; i < 100; i++) { snprintf(buf, sizeof(buf), "%s%d", "command", i); q = config_get(run->config, "", buf);