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:
gnome-control-center#2768 (closed)
gnome-control-center#2720 (closed)
gnome-control-center#2595 (closed)
gnome-control-center#2548 (closed)
The general way to reproduce these is:
- Open Gnome Control Center
- Open Displays panel
- Go to another panel
- Press Escape
- Crash
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 (closed) 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 (closed) is to make sure the phase is set to GTK_PHASE_BUBBLE
before the widget is disposed...
TLDR
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?
Relevant call chain code
gtk/gtkshortcutcontroller.c#L546-553
gtk/gtkshortcutcontroller.c#L694-737
gtk/gtkshortcutmanager.c#L100-118
gtk/gtkshortcutmanager.c#L65-82