[gtk/wip/otte/for-main: 4/4] x11: Don't delete important signal handlers randomly
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/for-main: 4/4] x11: Don't delete important signal handlers randomly
- Date: Mon, 13 Dec 2021 00:56:48 +0000 (UTC)
commit 252b9fc39cfb0b717b23d422dc05b02f7bb4088c
Author: Benjamin Otte <otte redhat com>
Date: Mon Dec 13 01:54:21 2021 +0100
x11: Don't delete important signal handlers randomly
We finish the write to the output stream long after the stream has been
closed, so we want to keep the event handler around to do just that.
Instead, remove the handler on finalize.
gdk/x11/gdkselectionoutputstream-x11.c | 64 ++++------------------------------
1 file changed, 7 insertions(+), 57 deletions(-)
---
diff --git a/gdk/x11/gdkselectionoutputstream-x11.c b/gdk/x11/gdkselectionoutputstream-x11.c
index 7371f1c0f3..da77d5db82 100644
--- a/gdk/x11/gdkselectionoutputstream-x11.c
+++ b/gdk/x11/gdkselectionoutputstream-x11.c
@@ -502,60 +502,6 @@ gdk_x11_selection_output_stream_flush_finish (GOutputStream *stream,
return g_task_propagate_boolean (G_TASK (result), error);
}
-static gboolean
-gdk_x11_selection_output_stream_invoke_close (gpointer stream)
-{
- GdkX11SelectionOutputStreamPrivate *priv = gdk_x11_selection_output_stream_get_instance_private (stream);
-
- GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams,
stream);
- g_signal_handlers_disconnect_by_func (priv->display,
- gdk_x11_selection_output_stream_xevent,
- stream);
- g_object_unref (stream);
-
- return G_SOURCE_REMOVE;
-}
-
-static gboolean
-gdk_x11_selection_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- g_main_context_invoke (NULL, gdk_x11_selection_output_stream_invoke_close, g_object_ref (stream));
-
- return TRUE;
-}
-
-static void
-gdk_x11_selection_output_stream_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GTask *task;
-
- task = g_task_new (stream, cancellable, callback, user_data);
- g_task_set_source_tag (task, gdk_x11_selection_output_stream_close_async);
- g_task_set_priority (task, io_priority);
-
- gdk_x11_selection_output_stream_invoke_close (stream);
- g_task_return_boolean (task, TRUE);
-
- g_object_unref (task);
-}
-
-static gboolean
-gdk_x11_selection_output_stream_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- g_return_val_if_fail (g_task_is_valid (result, stream), FALSE);
- g_return_val_if_fail (g_async_result_is_tagged (result, gdk_x11_selection_output_stream_close_async),
FALSE);
-
- return g_task_propagate_boolean (G_TASK (result), error);
-}
-
static void
gdk_x11_selection_output_stream_finalize (GObject *object)
{
@@ -565,6 +511,13 @@ gdk_x11_selection_output_stream_finalize (GObject *object)
/* not sending a notify is terrible */
g_assert (priv->notify == NULL);
+ GDK_DISPLAY_NOTE (priv->display, SELECTION, g_printerr ("%s:%s: finalizing\n",
+ priv->selection, priv->target));
+ GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams,
stream);
+ g_signal_handlers_disconnect_by_func (priv->display,
+ gdk_x11_selection_output_stream_xevent,
+ stream);
+
g_byte_array_unref (priv->data);
g_cond_clear (&priv->cond);
g_mutex_clear (&priv->mutex);
@@ -587,14 +540,11 @@ gdk_x11_selection_output_stream_class_init (GdkX11SelectionOutputStreamClass *kl
output_stream_class->write_fn = gdk_x11_selection_output_stream_write;
output_stream_class->flush = gdk_x11_selection_output_stream_flush;
- output_stream_class->close_fn = gdk_x11_selection_output_stream_close;
output_stream_class->write_async = gdk_x11_selection_output_stream_write_async;
output_stream_class->write_finish = gdk_x11_selection_output_stream_write_finish;
output_stream_class->flush_async = gdk_x11_selection_output_stream_flush_async;
output_stream_class->flush_finish = gdk_x11_selection_output_stream_flush_finish;
- output_stream_class->close_async = gdk_x11_selection_output_stream_close_async;
- output_stream_class->close_finish = gdk_x11_selection_output_stream_close_finish;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]