diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2019-10-21 11:40:41 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2020-01-17 13:57:24 +0100 |
commit | 4d0a331cfe0930de38d901cd20d1b0634eeb9f58 (patch) | |
tree | ce459991dcb59f0f42e606c35780bd512364c7c8 | |
parent | 01d93f281942be5869e8962a62feed9053bfc52f (diff) | |
download | mutter-4d0a331cfe0930de38d901cd20d1b0634eeb9f58.tar.gz |
x11: Detach selection streams on dispose
The streams were only detached from MetaX11Display (and its event handling)
on completion. This is too much to expect, and those might be in some
circumstances replaced while operating.
Make those streams detach themselves on dispose(), so we don't trip into
freed memory later on when trying to dispatch unrelated X11 selection events.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/869
(cherry picked from commit e1fa0734a9985c06b5a9cbd031d3563ad463904b)
-rw-r--r-- | src/x11/meta-x11-selection-input-stream.c | 15 | ||||
-rw-r--r-- | src/x11/meta-x11-selection-output-stream.c | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/x11/meta-x11-selection-input-stream.c b/src/x11/meta-x11-selection-input-stream.c index 44309ba98..e8d782047 100644 --- a/src/x11/meta-x11-selection-input-stream.c +++ b/src/x11/meta-x11-selection-input-stream.c @@ -262,6 +262,20 @@ meta_x11_selection_input_stream_close_finish (GInputStream *stream, } static void +meta_x11_selection_input_stream_dispose (GObject *object) +{ + MetaX11SelectionInputStream *stream = + META_X11_SELECTION_INPUT_STREAM (object); + MetaX11SelectionInputStreamPrivate *priv = + meta_x11_selection_input_stream_get_instance_private (stream); + + priv->x11_display->selection.input_streams = + g_list_remove (priv->x11_display->selection.input_streams, stream); + + G_OBJECT_CLASS (meta_x11_selection_input_stream_parent_class)->dispose (object); +} + +static void meta_x11_selection_input_stream_finalize (GObject *object) { MetaX11SelectionInputStream *stream = @@ -284,6 +298,7 @@ meta_x11_selection_input_stream_class_init (MetaX11SelectionInputStreamClass *kl GObjectClass *object_class = G_OBJECT_CLASS (klass); GInputStreamClass *istream_class = G_INPUT_STREAM_CLASS (klass); + object_class->dispose = meta_x11_selection_input_stream_dispose; object_class->finalize = meta_x11_selection_input_stream_finalize; istream_class->read_fn = meta_x11_selection_input_stream_read; diff --git a/src/x11/meta-x11-selection-output-stream.c b/src/x11/meta-x11-selection-output-stream.c index 723903835..86615364a 100644 --- a/src/x11/meta-x11-selection-output-stream.c +++ b/src/x11/meta-x11-selection-output-stream.c @@ -490,6 +490,20 @@ meta_x11_selection_output_stream_close_finish (GOutputStream *stream, } static void +meta_x11_selection_output_stream_dispose (GObject *object) +{ + MetaX11SelectionOutputStream *stream = + META_X11_SELECTION_OUTPUT_STREAM (object); + MetaX11SelectionOutputStreamPrivate *priv = + meta_x11_selection_output_stream_get_instance_private (stream); + + priv->x11_display->selection.output_streams = + g_list_remove (priv->x11_display->selection.output_streams, stream); + + G_OBJECT_CLASS (meta_x11_selection_output_stream_parent_class)->dispose (object); +} + +static void meta_x11_selection_output_stream_finalize (GObject *object) { MetaX11SelectionOutputStream *stream = @@ -514,6 +528,7 @@ meta_x11_selection_output_stream_class_init (MetaX11SelectionOutputStreamClass * GObjectClass *object_class = G_OBJECT_CLASS (klass); GOutputStreamClass *output_stream_class = G_OUTPUT_STREAM_CLASS (klass); + object_class->dispose = meta_x11_selection_output_stream_dispose; object_class->finalize = meta_x11_selection_output_stream_finalize; output_stream_class->write_fn = meta_x11_selection_output_stream_write; |