[PATCH 2/3] user32: Simplify GCLP_HICON and GCLP_HICONSM boolean logic.

Alex Henrie alexhenrie24 at gmail.com
Thu May 14 02:37:56 CDT 2015


GCLP_HICON:

hIconSmIntern is only set if hIcon is not null. Therefore, we do not
need to check that both hIcon and hIconSmIntern are not null; we only
need the more specific check that hIconSmIntern is not null.

GCLP_HICONSM:

hIconSmIntern is only set if hIconSm is null. The first if statement
guarantees that hIconSm is not null--and therefore that hIconSmIntern is
null--so we do not need to set hIconSmIntern to null again. In fact, if
hIconSmIntern were not null then setting it to null here would cause a
memory leak.

For the same reason, checking that both hIconSm is null and that
hIconSmIntern is not null in the second if statement is redundant. Only
the more specific check for hIconSmIntern is needed.
---
 dlls/user32/class.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/dlls/user32/class.c b/dlls/user32/class.c
index bc1e623..0b3582e 100644
--- a/dlls/user32/class.c
+++ b/dlls/user32/class.c
@@ -977,7 +977,7 @@ static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval,
         break;
     case GCLP_HICON:
         retval = (ULONG_PTR)class->hIcon;
-        if (retval && class->hIconSmIntern)
+        if (class->hIconSmIntern)
         {
             DestroyIcon(class->hIconSmIntern);
             class->hIconSmIntern = NULL;
@@ -990,12 +990,11 @@ static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval,
         break;
     case GCLP_HICONSM:
         retval = (ULONG_PTR)class->hIconSm;
-        if (retval && !newval)
-            class->hIconSmIntern = class->hIcon ? CopyImage( class->hIcon, IMAGE_ICON,
-                                                GetSystemMetrics( SM_CXSMICON ),
-                                                GetSystemMetrics( SM_CYSMICON ),
-                                                LR_COPYFROMRESOURCE ) : NULL;
-        else if (!retval && newval && class->hIconSmIntern)
+        if (retval && !newval && class->hIcon)
+            class->hIconSmIntern = CopyImage( class->hIcon, IMAGE_ICON,
+                      GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
+                      LR_COPYFROMRESOURCE );
+        else if (newval && class->hIconSmIntern)
         {
             DestroyIcon(class->hIconSmIntern);
             class->hIconSmIntern = NULL;
-- 
2.4.0




More information about the wine-patches mailing list