[gtk/fix-win32-empty-clipboard] gdkclipboard-win32.c: Fix call to gdk_clipboard_claim_remote()
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fix-win32-empty-clipboard] gdkclipboard-win32.c: Fix call to gdk_clipboard_claim_remote()
- Date: Thu, 31 Mar 2022 02:58:17 +0000 (UTC)
commit 8519ab56f51eeba585fe5b2d3f2ab3c322904621
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Thu Mar 31 10:36:45 2022 +0800
gdkclipboard-win32.c: Fix call to gdk_clipboard_claim_remote()
The call to gdk_win32_clipboard_request_contentformats() can return NULL even
without an error condition being hit (such as when the system clipboard is
empty), so check whether the returned GdkContentFormat pointer is not NULL
before calling gdk_clipboard_claim_remote(), which expects it to be not NULL,
otherwise we face a warning from that funtion and the subsequent
g_object_unref().
This at least partially fixes issue #4796.
gdk/win32/gdkclipboard-win32.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/gdk/win32/gdkclipboard-win32.c b/gdk/win32/gdkclipboard-win32.c
index 36d56b8b53..ce80019e56 100644
--- a/gdk/win32/gdkclipboard-win32.c
+++ b/gdk/win32/gdkclipboard-win32.c
@@ -142,9 +142,13 @@ gdk_win32_clipboard_claim_remote (GdkWin32Clipboard *cb)
cb->sequence_number = -1;
formats = gdk_win32_clipboard_request_contentformats (cb);
- gdk_clipboard_claim_remote (GDK_CLIPBOARD (cb), formats);
- gdk_content_formats_unref (formats);
- cb->sequence_number = GetClipboardSequenceNumber ();
+
+ if (formats != NULL)
+ {
+ gdk_clipboard_claim_remote (GDK_CLIPBOARD (cb), formats);
+ gdk_content_formats_unref (formats);
+ cb->sequence_number = GetClipboardSequenceNumber ();
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]