1
0
Fork 0

x11: Iterate over selections in a safer manner for event handling

It might be the case that handling an event induces the stream to
trigger completion, hence removing itself from the list. In that
case we would operate on the no longer valid list element to fetch
the next one.

Keep a pointer to the next element beforehand, so we can tiptoe
over streams that did remove themselves.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/869
This commit is contained in:
Carlos Garnacho 2019-10-21 12:58:35 +02:00
parent e1fa0734a9
commit 45a8806e65

View file

@ -1734,11 +1734,21 @@ process_selection_event (MetaX11Display *x11_display,
handled |= meta_x11_selection_handle_event (x11_display, event);
for (l = x11_display->selection.input_streams; l && !handled; l = l->next)
handled |= meta_x11_selection_input_stream_xevent (l->data, event);
for (l = x11_display->selection.input_streams; l && !handled;)
{
GList *next = l->next;
for (l = x11_display->selection.output_streams; l && !handled; l = l->next)
handled |= meta_x11_selection_output_stream_xevent (l->data, event);
handled |= meta_x11_selection_input_stream_xevent (l->data, event);
l = next;
}
for (l = x11_display->selection.output_streams; l && !handled;)
{
GList *next = l->next;
handled |= meta_x11_selection_output_stream_xevent (l->data, event);
l = next;
}
return handled;
}