[gtk/wip/otte/for-main: 2/4] x11: Explicitly close_async() the output stream
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/for-main: 2/4] x11: Explicitly close_async() the output stream
- Date: Mon, 13 Dec 2021 00:56:47 +0000 (UTC)
commit 66f1fef0830337de50731d0e44d5f1b133fe5208
Author: Benjamin Otte <otte redhat com>
Date: Mon Dec 13 01:43:24 2021 +0100
x11: Explicitly close_async() the output stream
We need to be very careful when writing data, because if we aren't, sync
functions will be called on the output stream and X11 does not like that
at all.
gdk/x11/gdkclipboard-x11.c | 28 ++++++++++++++++++++++++++--
gdk/x11/gdkdrag-x11.c | 28 ++++++++++++++++++++++++++--
2 files changed, 52 insertions(+), 4 deletions(-)
---
diff --git a/gdk/x11/gdkclipboard-x11.c b/gdk/x11/gdkclipboard-x11.c
index 404c8c7cd6..4335674102 100644
--- a/gdk/x11/gdkclipboard-x11.c
+++ b/gdk/x11/gdkclipboard-x11.c
@@ -76,11 +76,30 @@ print_atoms (GdkX11Clipboard *cb,
});
}
+static void
+gdk_x11_clipboard_default_output_closed (GObject *stream,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ if (!g_output_stream_close_finish (G_OUTPUT_STREAM (stream), result, &error))
+ {
+ GDK_NOTE (CLIPBOARD,
+ g_printerr ("-------: failed to close stream: %s\n",
+ error->message));
+ g_error_free (error);
+ }
+
+ g_object_unref (stream);
+}
+
static void
gdk_x11_clipboard_default_output_done (GObject *clipboard,
GAsyncResult *result,
gpointer user_data)
{
+ GOutputStream *stream = user_data;
GError *error = NULL;
if (!gdk_clipboard_write_finish (GDK_CLIPBOARD (clipboard), result, &error))
@@ -90,6 +109,12 @@ gdk_x11_clipboard_default_output_done (GObject *clipboard,
GDK_X11_CLIPBOARD (clipboard)->selection, error->message));
g_error_free (error);
}
+
+ g_output_stream_close_async (stream,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ gdk_x11_clipboard_default_output_closed,
+ NULL);
}
static void
@@ -103,8 +128,7 @@ gdk_x11_clipboard_default_output_handler (GOutputStream *stream,
G_PRIORITY_DEFAULT,
NULL,
gdk_x11_clipboard_default_output_done,
- NULL);
- g_object_unref (stream);
+ stream);
}
static GInputStream *
diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c
index 5804085a56..7e7904904b 100644
--- a/gdk/x11/gdkdrag-x11.c
+++ b/gdk/x11/gdkdrag-x11.c
@@ -1612,11 +1612,30 @@ gdk_x11_drag_set_hotspot (GdkDrag *drag,
}
}
+static void
+gdk_x11_drag_default_output_closed (GObject *stream,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ if (!g_output_stream_close_finish (G_OUTPUT_STREAM (stream), result, &error))
+ {
+ GDK_NOTE (DND,
+ g_printerr ("failed to close stream: %s\n",
+ error->message));
+ g_error_free (error);
+ }
+
+ g_object_unref (stream);
+}
+
static void
gdk_x11_drag_default_output_done (GObject *drag,
GAsyncResult *result,
gpointer user_data)
{
+ GOutputStream *stream = user_data;
GError *error = NULL;
if (!gdk_drag_write_finish (GDK_DRAG (drag), result, &error))
@@ -1624,6 +1643,12 @@ gdk_x11_drag_default_output_done (GObject *drag,
GDK_DISPLAY_NOTE (gdk_drag_get_display (GDK_DRAG (drag)), DND, g_printerr ("failed to write stream:
%s\n", error->message));
g_error_free (error);
}
+
+ g_output_stream_close_async (stream,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ gdk_x11_drag_default_output_closed,
+ NULL);
}
static void
@@ -1637,8 +1662,7 @@ gdk_x11_drag_default_output_handler (GOutputStream *stream,
G_PRIORITY_DEFAULT,
NULL,
gdk_x11_drag_default_output_done,
- NULL);
- g_object_unref (stream);
+ stream);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]