Ziqing Hui : user32: Add an is_shared member to cursoricon_object.
Alexandre Julliard
julliard at winehq.org
Wed Dec 8 15:46:30 CST 2021
Module: wine
Branch: master
Commit: 9e74b207cfd9d1d866bdfbd61a165456430b70db
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9e74b207cfd9d1d866bdfbd61a165456430b70db
Author: Ziqing Hui <zhui at codeweavers.com>
Date: Tue Dec 7 18:06:45 2021 +0800
user32: Add an is_shared member to cursoricon_object.
It makes sure that shared icon/cursor created by CreateIconFromResourceEx()
won't be destroyed by Destroy{Icon,Cursor}().
Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/cursoricon.c | 13 +++++++++----
dlls/user32/tests/cursoricon.c | 2 --
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index ba5c5d8904c..f107255c8c0 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -76,6 +76,7 @@ struct cursoricon_object
HMODULE module; /* module for icons loaded from resources */
LPWSTR resname; /* resource name for icons loaded from resources */
HRSRC rsrc; /* resource for shared icons */
+ BOOL is_shared; /* whether this object is shared */
BOOL is_icon; /* whether icon or cursor */
BOOL is_ani; /* whether this object is a static cursor or an animated cursor */
UINT delay; /* delay between this frame and the next (in jiffies) */
@@ -1224,10 +1225,14 @@ done:
}
else info->resname = MAKEINTRESOURCEW( LOWORD(resname) );
- if (module && (cFlag & LR_SHARED))
+ if (cFlag & LR_SHARED)
{
- info->rsrc = rsrc;
- list_add_head( &icon_cache, &info->entry );
+ info->is_shared = TRUE;
+ if (module)
+ {
+ info->rsrc = rsrc;
+ list_add_head( &icon_cache, &info->entry );
+ }
}
release_user_handle_ptr( info );
}
@@ -1871,7 +1876,7 @@ BOOL WINAPI DestroyIcon( HICON hIcon )
if (obj)
{
- BOOL shared = (obj->rsrc != NULL);
+ BOOL shared = obj->is_shared;
release_user_handle_ptr( obj );
ret = (NtUserGetCursor() != hIcon);
if (!shared) free_icon_handle( hIcon );
diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c
index fac330bd7e9..a4bdc4f13cf 100644
--- a/dlls/user32/tests/cursoricon.c
+++ b/dlls/user32/tests/cursoricon.c
@@ -1709,7 +1709,6 @@ static void test_CreateIconFromResource(void)
ret = DestroyIcon(handle);
ok(ret, "Destroy icon failed, error %u.\n", GetLastError());
ret = GetIconInfo(handle, &icon_info);
- todo_wine
ok(ret, "Get info failed, error %u.\n", GetLastError());
/* Test creating a shared icon from heap bits that has been created before. */
@@ -1747,7 +1746,6 @@ static void test_CreateIconFromResource(void)
ret = DestroyIcon(handle);
ok(ret, "Destroy icon failed, error %u.\n", GetLastError());
ret = GetIconInfo(handle, &icon_info);
- todo_wine
ok(ret, "Get info failed, error %u.\n", GetLastError());
/* Test creating a shared icon from resource bits that has been created before. */
More information about the wine-cvs
mailing list