[gtk/wip/matthiasc/focus2: 24/33] Protect against focus cycles
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/focus2: 24/33] Protect against focus cycles
- Date: Sun, 3 Mar 2019 20:36:49 +0000 (UTC)
commit fa95bc747d8f1590a57f61d5d350694433e48320
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 3 02:52:57 2019 -0500
Protect against focus cycles
Now that next_focus_child wraps around for windows,
GtkMenus cause an infinite lookp in next_Focus_child.
Prevent that.
gtk/gtkwidgetfocus.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwidgetfocus.c b/gtk/gtkwidgetfocus.c
index 2be4f75369..691275d701 100644
--- a/gtk/gtkwidgetfocus.c
+++ b/gtk/gtkwidgetfocus.c
@@ -465,6 +465,9 @@ gtk_widget_get_next_focus (GtkWidget *widget,
{
GtkWidget *prev;
GtkWidget *next;
+ GHashTable *seen;
+
+ seen = g_hash_table_new (g_direct_hash, g_direct_equal);
prev = NULL;
do {
@@ -476,16 +479,23 @@ gtk_widget_get_next_focus (GtkWidget *widget,
}
else if (gtk_widget_get_can_focus (next))
{
- return next;
+ break;
+ }
+ else if (g_hash_table_contains (seen, next))
+ {
+ next = NULL;
+ break;
}
else
{
+ g_hash_table_add (seen, next);
widget = next;
prev = NULL;
}
} while (widget);
- return NULL;
+ g_hash_table_unref (seen);
+ return next;
}
GtkWidget *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]