Module: wine Branch: master Commit: 9e351472dd5fc7a9ceb0aacaadfd431ea38a974e URL: https://gitlab.winehq.org/wine/wine/-/commit/9e351472dd5fc7a9ceb0aacaadfd431...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Dec 21 13:46:33 2022 +0100
shell32: Always set last error in Shell_NotifyIconW.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53101
---
dlls/shell32/systray.c | 8 +++++++- dlls/shell32/tests/systray.c | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/dlls/shell32/systray.c b/dlls/shell32/systray.c index 6916937c41b..7863c4de177 100644 --- a/dlls/shell32/systray.c +++ b/dlls/shell32/systray.c @@ -148,7 +148,11 @@ BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW nid) }
tray = FindWindowExW(0, NULL, L"Shell_TrayWnd", NULL); - if (!tray) return FALSE; + if (!tray) + { + SetLastError(E_FAIL); + return FALSE; + }
cds.dwData = dwMessage; cds.cbData = sizeof(*data); @@ -185,6 +189,7 @@ BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW nid) { DeleteObject(iconinfo.hbmMask); if (iconinfo.hbmColor) DeleteObject(iconinfo.hbmColor); + SetLastError(E_OUTOFMEMORY); return FALSE; }
@@ -241,6 +246,7 @@ noicon: cds.lpData = data; ret = SendMessageW(tray, WM_COPYDATA, (WPARAM)nid->hWnd, (LPARAM)&cds); if (data != &data_buffer) heap_free( data ); + SetLastError(ret ? S_OK : E_FAIL); return ret; }
diff --git a/dlls/shell32/tests/systray.c b/dlls/shell32/tests/systray.c index ba5832e51c7..80621761240 100644 --- a/dlls/shell32/tests/systray.c +++ b/dlls/shell32/tests/systray.c @@ -44,8 +44,11 @@ static void test_cbsize(void) nidW.uFlags = NIF_ICON|NIF_MESSAGE; nidW.hIcon = LoadIconA(NULL, (LPSTR)IDI_APPLICATION); nidW.uCallbackMessage = WM_USER+17; + SetLastError(0xdeadbeef); ret = pShell_NotifyIconW(NIM_ADD, &nidW); ok(ret, "NIM_ADD failed!\n"); + ok(GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_NO_TOKEN, + "GetLastError() = %lu\n", GetLastError()); /* using an invalid cbSize does work */ nidW.cbSize = 3; nidW.hWnd = hMainWnd; @@ -54,7 +57,10 @@ static void test_cbsize(void) ok( ret || broken(!ret), /* nt4 */ "NIM_DELETE failed!\n"); /* as icon doesn't exist anymore - now there will be an error */ nidW.cbSize = sizeof(nidW); + SetLastError(0xdeadbeef); ok(!pShell_NotifyIconW(NIM_DELETE, &nidW) != !ret, "The icon was not deleted\n"); + ok(GetLastError() == E_FAIL || GetLastError() == ERROR_TIMEOUT, + "GetLastError() = %lu\n", GetLastError()); }
/* same for Shell_NotifyIconA */ @@ -65,7 +71,10 @@ static void test_cbsize(void) nidA.uFlags = NIF_ICON|NIF_MESSAGE; nidA.hIcon = LoadIconA(NULL, (LPSTR)IDI_APPLICATION); nidA.uCallbackMessage = WM_USER+17; + SetLastError(0xdeadbeef); ok(Shell_NotifyIconA(NIM_ADD, &nidA), "NIM_ADD failed!\n"); + ok(GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_NO_TOKEN, + "GetLastError() = %lu\n", GetLastError());
/* using an invalid cbSize does work */ nidA.cbSize = 3; @@ -75,7 +84,10 @@ static void test_cbsize(void) ok(ret, "NIM_DELETE failed!\n"); /* as icon doesn't exist anymore - now there will be an error */ nidA.cbSize = sizeof(nidA); + SetLastError(0xdeadbeef); ok(!Shell_NotifyIconA(NIM_DELETE, &nidA) != !ret, "The icon was not deleted\n"); + ok(GetLastError() == E_FAIL || GetLastError() == ERROR_TIMEOUT, + "GetLastError() = %lu\n", GetLastError()); }
START_TEST(systray)