[nautilus] window-menus: disconnect from GtkSettings notifications on finalize
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] window-menus: disconnect from GtkSettings notifications on finalize
- Date: Tue, 12 Jun 2012 16:05:19 +0000 (UTC)
commit 2ec2ff031277e85a8e3a636fedd57ddc61494026
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Jun 12 12:03:26 2012 -0400
window-menus: disconnect from GtkSettings notifications on finalize
Or if something (e.g. another process via xsettings) causes the
GtkSettings to change the value of gtk-shell-shows-app-menu after a
window is finalized, our callback will run and we'll crash trying to
access freed memory.
https://bugzilla.gnome.org/show_bug.cgi?id=677945
src/nautilus-window-menus.c | 13 ++++++++++---
src/nautilus-window-private.h | 1 +
2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 4189823..6d8b7cc 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -857,9 +857,10 @@ nautilus_window_initialize_menus (NautilusWindow *window)
window);
nautilus_window_menus_set_visibility_for_app_menu (window);
- g_signal_connect_swapped (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
- "notify::gtk-shell-shows-app-menu",
- G_CALLBACK (nautilus_window_menus_set_visibility_for_app_menu), window);
+ window->details->app_menu_visibility_id =
+ g_signal_connect_swapped (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
+ "notify::gtk-shell-shows-app-menu",
+ G_CALLBACK (nautilus_window_menus_set_visibility_for_app_menu), window);
action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_UP);
g_object_set (action, "short_label", _("_Up"), NULL);
@@ -929,6 +930,12 @@ nautilus_window_finalize_menus (NautilusWindow *window)
g_signal_handlers_disconnect_by_func (nautilus_preferences,
show_hidden_files_preference_callback, window);
+
+ if (window->details->app_menu_visibility_id != 0) {
+ g_signal_handler_disconnect (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
+ window->details->app_menu_visibility_id);
+ window->details->app_menu_visibility_id = 0;
+ }
}
static GList *
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index 0d7a4b3..42d48f0 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -97,6 +97,7 @@ struct NautilusWindowDetails
gboolean disable_chrome;
guint sidebar_width_handler_id;
+ guint app_menu_visibility_id;
};
/* window geometry */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]