[mutter/wip/carlosg/x11-selection-detach] x11: Iterate over selections in a safer manner for event handling
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/x11-selection-detach] x11: Iterate over selections in a safer manner for event handling
- Date: Mon, 21 Oct 2019 11:20:25 +0000 (UTC)
commit 45a8806e652346523cb66fb4777e15b63aa90c2a
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Oct 21 12:58:35 2019 +0200
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
src/x11/events.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/x11/events.c b/src/x11/events.c
index 7fc7e3bf9..95cc714d0 100644
--- a/src/x11/events.c
+++ b/src/x11/events.c
@@ -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;
+
+ handled |= meta_x11_selection_input_stream_xevent (l->data, event);
+ l = next;
+ }
- for (l = x11_display->selection.output_streams; l && !handled; l = l->next)
- handled |= meta_x11_selection_output_stream_xevent (l->data, event);
+ 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]