mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-13 12:20:10 +00:00
gesture: Prevent against sequence cancellation within gtk_gesture_set_state()
Sequences may be cancelled within the ::sequence-state-changed handler, which would change the points hashtable as it's being iterated in this function. So iterate over a list of sequences and let the hashtable change freely.
This commit is contained in:
parent
44a960199b
commit
2a0bf33bc9
@ -845,20 +845,21 @@ gboolean
|
||||
gtk_gesture_set_state (GtkGesture *gesture,
|
||||
GtkEventSequenceState state)
|
||||
{
|
||||
GdkEventSequence *sequence;
|
||||
gboolean handled = FALSE;
|
||||
GtkGesturePrivate *priv;
|
||||
GHashTableIter iter;
|
||||
GList *sequences, *l;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_GESTURE (gesture), FALSE);
|
||||
g_return_val_if_fail (state >= GTK_EVENT_SEQUENCE_NONE &&
|
||||
state <= GTK_EVENT_SEQUENCE_DENIED, FALSE);
|
||||
|
||||
priv = gtk_gesture_get_instance_private (gesture);
|
||||
g_hash_table_iter_init (&iter, priv->points);
|
||||
sequences = g_hash_table_get_keys (priv->points);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, (gpointer*) &sequence, NULL))
|
||||
handled |= gtk_gesture_set_sequence_state (gesture, sequence, state);
|
||||
for (l = sequences; l; l = l->next)
|
||||
handled |= gtk_gesture_set_sequence_state (gesture, l->data, state);
|
||||
|
||||
g_list_free (sequences);
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user