aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2021-10-13 02:06:49 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2021-10-13 16:32:31 +0300
commit33a16ae04270647e99dc0741b706061e6468fa3c (patch)
tree085af7971cbda626fa46a88b0e66c832cef37b20
parent3ed4116a989036b454f22471736ceba0084b68ca (diff)
downloadsciteco-33a16ae04270647e99dc0741b706061e6468fa3c.tar.gz
GTK: prevent crashes when pressing keys very quickly
* teco_interface_key_pressed_cb() could be called multiple times __before__ the idle timer (teco_interface_pop_key_idle_cb()) fires. The recursion check would consequently not work and we started the idle timer multiple times. This would eventually crash. * We now process the first queued key immediately. The alternative would be to store the idle watcher id. * The idle watcher's priority has been increased. Since redrawing is guaranteed to take place at G_PRIORITY_HIGH_IDLE, it is sufficient to process keys at G_PRIORITY_DEFAULT_IDLE. * Should also reduce latency slightly. * fixes up 71bf522231d2998f1fb183f343c2b1f9dbcd3b15
-rw-r--r--src/interface-gtk/interface.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c
index 20b1e5d..27c043c 100644
--- a/src/interface-gtk/interface.c
+++ b/src/interface-gtk/interface.c
@@ -1187,7 +1187,8 @@ teco_interface_key_pressed_cb(GtkWidget *widget, GdkEventKey *event, gpointer us
* a key pressed could result in the UI beeing frozen until the
* key is eventually released.
*/
- g_idle_add_full(G_PRIORITY_LOW, teco_interface_pop_key_idle_cb, NULL, NULL);
+ if (teco_interface_pop_key_idle_cb(NULL) == G_SOURCE_CONTINUE)
+ g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, teco_interface_pop_key_idle_cb, NULL, NULL);
return TRUE;
}