Francois Gouget : user32/tests: GetClipboardData() returns no error for missing formats.

Alexandre Julliard julliard at winehq.org
Mon Aug 9 16:21:44 CDT 2021


Module: wine
Branch: master
Commit: 9bd3e3fbe9c4fdee5e542b7f64f94af4038d4218
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=9bd3e3fbe9c4fdee5e542b7f64f94af4038d4218

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Sun Aug  8 00:48:28 2021 +0200

user32/tests: GetClipboardData() returns no error for missing formats.

Despite the documentation that says if GetClipboardData() returns NULL
one can check GetLastError() to know why!

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/clipboard.c       | 1 +
 dlls/user32/tests/clipboard.c | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/dlls/user32/clipboard.c b/dlls/user32/clipboard.c
index e8de7d9bdf6..a13085719a9 100644
--- a/dlls/user32/clipboard.c
+++ b/dlls/user32/clipboard.c
@@ -1070,6 +1070,7 @@ HANDLE WINAPI GetClipboardData( UINT format )
         GlobalFree( data );
 
         if (status == STATUS_BUFFER_OVERFLOW) continue;  /* retry with the new size */
+        if (status == STATUS_OBJECT_NAME_NOT_FOUND) return 0; /* no such format */
         if (status)
         {
             SetLastError( RtlNtStatusToDosError( status ));
diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c
index b10ffaf4c8f..f351a6a29a8 100644
--- a/dlls/user32/tests/clipboard.c
+++ b/dlls/user32/tests/clipboard.c
@@ -1543,6 +1543,11 @@ static void test_handles( HWND hwnd )
     data = GetClipboardData( 0xdeadfade );
     ok( data == ptr, "wrong data %p\n", data );
 
+    SetLastError( 0xdeadbeef );
+    data = GetClipboardData( CF_RIFF );
+    ok( GetLastError() == 0xdeadbeef, "unexpected last error %d\n", GetLastError() );
+    ok( !data, "wrong data %p\n", data );
+
     h = SetClipboardData( CF_PRIVATEFIRST + 7, htext4 );
     ok( h == htext4, "got %p\n", h );
     ok( is_moveable( h ), "expected moveable mem %p\n", h );




More information about the wine-cvs mailing list