x11: Make sure stream stays alive long enough

When unreffing the stream from a different thread, the close function
will schedule its cleanup asynchornously in the main thread.
We need to make sure the stream object stays alive for as long as
that hasn't happened, so ref() it.

Fixes #2003
This commit is contained in:
Benjamin Otte 2019-07-05 20:55:54 +02:00
parent 6455a54f6c
commit 96b782c026

View File

@ -503,6 +503,7 @@ gdk_x11_selection_output_stream_invoke_close (gpointer stream)
g_signal_handlers_disconnect_by_func (priv->display,
gdk_x11_selection_output_stream_xevent,
stream);
g_object_unref (stream);
return G_SOURCE_REMOVE;
}
@ -512,7 +513,7 @@ gdk_x11_selection_output_stream_close (GOutputStream *stream,
GCancellable *cancellable,
GError **error)
{
g_main_context_invoke (NULL, gdk_x11_selection_output_stream_invoke_close, stream);
g_main_context_invoke (NULL, gdk_x11_selection_output_stream_invoke_close, g_object_ref (stream));
return TRUE;
}