[PATCH 1/4] winex11.drv: Preserve last error in x11drv_thread_data().
Rafał Harabień
rafalh1992 at o2.pl
Sun Nov 12 17:32:16 CST 2017
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 at o2.pl>
---
dlls/user32/tests/input.c | 10 +++++++++-
dlls/winex11.drv/x11drv.h | 7 ++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 8f2576d..0f0f137 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -1928,8 +1928,16 @@ 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, "error %lu\n", GetLastError());
+
+ 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 */
--
2.7.4
More information about the wine-devel
mailing list