Issue was caused by TlsGetValue always resetting error to ERROR_SUCCESS. This change fixes GetCursorPos resetting last-error randomly.
Signed-off-by: Rafał Harabień rafalh1992@o2.pl --- dlls/user32/tests/input.c | 11 ++++++++++- dlls/winex11.drv/x11drv.h | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 8f2576d..6ce03f8 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -1928,8 +1928,17 @@ static void test_Input_mouse(void) DWORD thread_id; POINT pt, pt_org; MSG msg; + BOOL ret;
- GetCursorPos(&pt_org); + SetLastError(0xdeadbeef); + ret = GetCursorPos(NULL); + ok(!ret, "GetCursorPos succeed\n"); + ok(GetLastError() == 0xdeadbeef || GetLastError() == ERROR_NOACCESS, "error %lu\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = GetCursorPos(&pt_org); + ok(ret, "GetCursorPos failed\n"); + ok(GetLastError() == 0xdeadbeef, "error %lu\n", GetLastError());
button_win = CreateWindowA("button", "button", WS_VISIBLE | WS_POPUP, 100, 100, 100, 100, 0, NULL, NULL, NULL); diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 721c082..6786a08 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -345,7 +345,12 @@ extern DWORD thread_data_tls_index DECLSPEC_HIDDEN;
static inline struct x11drv_thread_data *x11drv_thread_data(void) { - return TlsGetValue( thread_data_tls_index ); + /* TlsGetValue always resets last error */ + unsigned long err = GetLastError(); + struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index ); + if (err != ERROR_SUCCESS && GetLastError() == ERROR_SUCCESS) + SetLastError(err); + return data; }
/* retrieve the thread display, or NULL if not created yet */
Rafał Harabień rafalh1992@o2.pl writes:
Issue was caused by TlsGetValue always resetting error to ERROR_SUCCESS. This change fixes GetCursorPos resetting last-error randomly.
Signed-off-by: Rafał Harabień rafalh1992@o2.pl
This will also require fixes in other places apparently:
../../../tools/runtest -q -P wine -T ../../.. -M user32.dll -p user32_test.exe.so dialog && touch dialog.ok dialog.c:1277: Test failed: got 1411 Makefile:346: recipe for target 'dialog.ok' failed make[1]: *** [dialog.ok] Error 1 ../../../tools/runtest -q -P wine -T ../../.. -M user32.dll -p user32_test.exe.so menu && touch menu.ok menu.c:3669: Tests skipped: interactive alignment tests. menu.c:2356: Tests skipped: test 27: failed to send input menu.c:3417: Test failed: TrackPopupMenu error got 5 expected 0 or 1401 menu.c:3417: Test failed: TrackPopupMenuEx error got 5 expected 0 or 1401 Makefile:466: recipe for target 'menu.ok' failed make[1]: *** [menu.ok] Error 2