From 41930e1edd8f61fc4274cc4e8993393cfa837ab9 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 5 Nov 2012 20:13:05 -0800 Subject: Fix incorrect variable reuse bug in preferences dialog This was introduced in commit ee803ef5d85b "Change preferences into a notebook and add second page for tec settings" In order to be able to get the new default XML file name back from the button, we need to keep that variable around and not overwrite it with more buttons for the tec preferences page. Reported-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- gtk-gui.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gtk-gui.c b/gtk-gui.c index e5b35f468..b14abb75b 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -568,7 +568,7 @@ static void pick_default_file(GtkWidget *w, GtkButton *button) static void preferences_dialog(GtkWidget *w, gpointer data) { int result; - GtkWidget *dialog, *notebook, *font, *frame, *box, *vbox, *button; + GtkWidget *dialog, *notebook, *font, *frame, *box, *vbox, *button, *xmlfile_button; const char *current_default, *new_default; menu_units = output_units; @@ -677,9 +677,10 @@ static void preferences_dialog(GtkWidget *w, gpointer data) box = gtk_hbox_new(FALSE, 6); gtk_container_add(GTK_CONTAINER(frame), box); current_default = subsurface_default_filename(); - button = gtk_button_new_with_label(current_default); - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(pick_default_file), button); - gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); + xmlfile_button = gtk_button_new_with_label(current_default); + g_signal_connect(G_OBJECT(xmlfile_button), "clicked", + G_CALLBACK(pick_default_file), xmlfile_button); + gtk_box_pack_start(GTK_BOX(box), xmlfile_button, FALSE, FALSE, 6); /* vbox that holds the second notebook page */ vbox = gtk_vbox_new(FALSE, 6); @@ -755,7 +756,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data) subsurface_set_conf("pn2graph", PREF_BOOL, BOOL_TO_PTR(enabled_graphs.pn2)); subsurface_set_conf("phegraph", PREF_BOOL, BOOL_TO_PTR(enabled_graphs.phe)); - new_default = strdup(gtk_button_get_label(GTK_BUTTON(button))); + new_default = strdup(gtk_button_get_label(GTK_BUTTON(xmlfile_button))); /* if we opened the default file and are changing its name, * update existing_filename */ -- cgit v1.2.3-70-g09d2