From 028dc2efd846defe796c7fa097ed84818bb43431 Mon Sep 17 00:00:00 2001 From: Nick Schermer Date: Sun, 21 Mar 2010 22:05:31 +0000 Subject: Disconnect bindings before closing the dialog. This avoids possible problems when Gtk+ emits property changes before the widgets are destroyed. This is currently the case for text entries in some Gtk 2.18 releases. --- diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c index 587bd92..8f33628 100644 --- a/terminal/terminal-preferences-dialog.c +++ b/terminal/terminal-preferences-dialog.c @@ -64,24 +64,28 @@ terminal_preferences_dialog_class_init (TerminalPreferencesDialogClass *klass) #define BIND_PROPERTIES(name, property) \ - { object = gtk_builder_get_object (GTK_BUILDER (dialog), name); \ + G_STMT_START { \ + object = gtk_builder_get_object (GTK_BUILDER (dialog), name); \ terminal_return_if_fail (G_IS_OBJECT (object)); \ - exo_mutual_binding_new (G_OBJECT (dialog->preferences), name, \ - G_OBJECT (object), property); } + binding = exo_mutual_binding_new (G_OBJECT (dialog->preferences), name, \ + G_OBJECT (object), property); \ + dialog->bindings = g_slist_prepend (dialog->bindings, binding); \ + } G_STMT_END static void terminal_preferences_dialog_init (TerminalPreferencesDialog *dialog) { - GError *error = NULL; - guint i; - GObject *object, *object2; - GtkWidget *editor; - gchar palette_name[16]; - GtkFileFilter *filter; - gchar *file; - const gchar *props_active[] = { "title-mode", "command-login-shell", + GError *error = NULL; + guint i; + GObject *object, *object2; + GtkWidget *editor; + gchar palette_name[16]; + GtkFileFilter *filter; + gchar *file; + ExoMutualBinding *binding; + const gchar *props_active[] = { "title-mode", "command-login-shell", "command-update-records", "scrolling-single-line", "scrolling-on-output", "scrolling-on-keystroke", "scrolling-bar", "font-allow-bold", @@ -94,9 +98,9 @@ terminal_preferences_dialog_init (TerminalPreferencesDialog *dialog) , "font-anti-alias" #endif }; - const gchar *props_color[] = { "color-foreground", "color-cursor", - "color-background", "tab-activity-color", - "color-selection" }; + const gchar *props_color[] = { "color-foreground", "color-cursor", + "color-background", "tab-activity-color", + "color-selection" }; dialog->preferences = terminal_preferences_get (); @@ -248,6 +252,8 @@ terminal_preferences_dialog_response (GtkWidget *widget, gint response, TerminalPreferencesDialog *dialog) { + GSList *li; + /* check if we should open the user manual */ if (G_UNLIKELY (response == 1)) { @@ -256,6 +262,11 @@ terminal_preferences_dialog_response (GtkWidget *widget, } else { + /* disconnect all the bindings */ + for (li = dialog->bindings; li != NULL; li = li->next) + exo_mutual_binding_unbind (li->data); + g_slist_free (dialog->bindings); + /* close the preferences dialog */ gtk_widget_destroy (widget); } diff --git a/terminal/terminal-preferences-dialog.h b/terminal/terminal-preferences-dialog.h index b2db4f5..268d70a 100644 --- a/terminal/terminal-preferences-dialog.h +++ b/terminal/terminal-preferences-dialog.h @@ -48,6 +48,7 @@ struct _TerminalPreferencesDialog TerminalPreferences *preferences; guint signal_id; + GSList *bindings; }; GType terminal_preferences_dialog_get_type (void) G_GNUC_CONST; -- cgit v0.8.2.1