Crash due to problem in GtkShortcutManager default implementation for GTK_PHASE_NONE
I believe GtkShortcutControllers that are added to a widget with Managed or Global scope, and are left on
GTK_PHASE_NONE, are not properly removed from the root GtkShortcutManager upon widget disposal. This leaves them lingering with a reference inside the GtkShortcutManager, without being cleaned up. This causes crashes when any shortcut keys that were set on them are activated, because their attached widget does not exist anymore.
The following Gnome Settings bug reports are basically caused by this issue:
The general way to reproduce these is:
- Open Gnome Control Center
- Open Displays panel
- Go to another panel
- Press Escape
These are hard to debug, because the crash can happen anywhere when you press Escape after leaving the Displays panel. In particular, I can verify that gnome-control-center#2768 is fixed when you change
gtk_shortcut_manager_default_remove_controller () to always remove the controller, even on
GTK_PHASE_NONE. So, I'm fairly confident this is a GTK problem. The only way around the crash in gnome-control-center#2768 is to make sure the phase is set to
GTK_PHASE_BUBBLE before the widget is disposed...
A GtkShortcutController with
GTK_PHASE_BUBBLE can be added to GtkShortcutManager, but then when its phase changes to
GTK_PHASE_NONE, it can't be removed again. Best action would probably be to do something in
set_propagation_phase for a GtkShortcutController?