[WIN32K]
authorJérôme Gardou <jerome.gardou@reactos.org>
Thu, 23 Oct 2014 11:46:01 +0000 (11:46 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Thu, 23 Oct 2014 11:46:01 +0000 (11:46 +0000)
 - Use shared icon handles when copying the small class icon from the larger one.
CORE-7575

svn path=/trunk/; revision=64920

reactos/win32ss/user/ntuser/class.c
reactos/win32ss/user/ntuser/window.c

index 8fa1614..98e6b1a 100644 (file)
@@ -248,10 +248,10 @@ IntDestroyClass(IN OUT PCLS Class)
 #ifdef NEW_CURSORICON
     if (Class->spicn)
         UserDereferenceObject(Class->spicn);
-    if (Class->spicnSm)
-        UserDereferenceObject(Class->spicnSm);
     if (Class->spcur)
         UserDereferenceObject(Class->spcur);
+    if (Class->spicnSm)
+        UserDereferenceObject(Class->spicnSm);
 #else
     if (Class->hIconSmIntern)
         IntClassDestroyIcon(Class->hIconSmIntern);
@@ -1976,18 +1976,31 @@ UserSetClassLongPtr(IN PCLS Class,
             if (NewLong && !Class->spicnSm)
             {
                 /* Create the new small icon from the new large(?) one */
-                HICON SmallIconHandle = co_IntCopyImage(
-                    (HICON)NewLong,
-                    IMAGE_ICON,
-                    UserGetSystemMetrics( SM_CXSMICON ),
-                    UserGetSystemMetrics( SM_CYSMICON ),
-                    0);
+                HICON SmallIconHandle = NULL;
+                if((NewIcon->CURSORF_flags & (CURSORF_LRSHARED | CURSORF_FROMRESOURCE))
+                        == (CURSORF_LRSHARED | CURSORF_FROMRESOURCE))
+                {
+                    SmallIconHandle = co_IntCopyImage(
+                        (HICON)NewLong,
+                        IMAGE_ICON,
+                        UserGetSystemMetrics( SM_CXSMICON ),
+                        UserGetSystemMetrics( SM_CYSMICON ),
+                        LR_COPYFROMRESOURCE | LR_SHARED);
+                }
+                if (!SmallIconHandle)
+                {
+                    /* Retry without copying from resource */
+                    SmallIconHandle = co_IntCopyImage(
+                        (HICON)NewLong,
+                        IMAGE_ICON,
+                        UserGetSystemMetrics( SM_CXSMICON ),
+                        UserGetSystemMetrics( SM_CYSMICON ),
+                        LR_SHARED);
+                }
                 if (SmallIconHandle)
                 {
                     /* So use it */
                     NewSmallIcon = Class->spicnSm = UserGetCurIconObject(SmallIconHandle);
-                    /* Let the handle go, we have the reference on the object */
-                    NtUserDestroyCursor(SmallIconHandle, FALSE);
                     Class->CSF_flags |= CSF_CACHEDSMICON;
                 }
             }
index 9d76efe..669703b 100644 (file)
@@ -1677,17 +1677,31 @@ PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs,
 #ifdef NEW_CURSORICON
    if (Class->spicn && !Class->spicnSm)
    {
-       HICON IconSmHandle = co_IntCopyImage(
-           UserHMGetHandle(Class->spicn),
-           IMAGE_ICON,
-           UserGetSystemMetrics( SM_CXSMICON ),
-           UserGetSystemMetrics( SM_CYSMICON ),
-           0);
+       HICON IconSmHandle = NULL;
+       if((Class->spicn->CURSORF_flags & (CURSORF_LRSHARED | CURSORF_FROMRESOURCE))
+               == (CURSORF_LRSHARED | CURSORF_FROMRESOURCE))
+       {
+           IconSmHandle = co_IntCopyImage(
+               UserHMGetHandle(Class->spicn),
+               IMAGE_ICON,
+               UserGetSystemMetrics( SM_CXSMICON ),
+               UserGetSystemMetrics( SM_CYSMICON ),
+               LR_COPYFROMRESOURCE | LR_SHARED);
+       }
+       if (!IconSmHandle)
+       {
+           /* Retry without copying from resource */
+           IconSmHandle = co_IntCopyImage(
+               UserHMGetHandle(Class->spicn),
+               IMAGE_ICON,
+               UserGetSystemMetrics( SM_CXSMICON ),
+               UserGetSystemMetrics( SM_CYSMICON ),
+               LR_SHARED);
+       }
+
        if (IconSmHandle)
        {
            Class->spicnSm = UserGetCurIconObject(IconSmHandle);
-           /* We can delete the handle, only the pointer is of interest */
-           NtUserDestroyCursor(IconSmHandle, FALSE);
            Class->CSF_flags |= CSF_CACHEDSMICON;
        }
    }