winemenubuilder: Fixed problem when extracting icon

Sven Paschukat Sven.Paschukat at t-online.de
Wed Jun 29 18:15:30 CDT 2005


The removing of the wine config file led to a problem when accessing the 
registry key HKLM\Software\Wine\Wine\Config\Wine\IconsDir which is not 
available by default and so the icons are not extracted. This patch uses 
always the TempPath if the key is missing.

Changelog:
Repaired extraction of icons when config file is missing

Sven
-------------- next part --------------
Index: programs/winemenubuilder/winemenubuilder.c
===================================================================
RCS file: /home/wine/wine/programs/winemenubuilder/winemenubuilder.c,v
retrieving revision 1.30
diff -u -p -r1.30 winemenubuilder.c
--- programs/winemenubuilder/winemenubuilder.c	13 Jun 2005 18:56:00 -0000	1.30
+++ programs/winemenubuilder/winemenubuilder.c	29 Jun 2005 22:38:24 -0000
@@ -445,42 +445,40 @@ static char *extract_icon( LPCWSTR path,
     /* Where should we save the icon? */
     WINE_TRACE("path=[%s] index=%d\n", wine_dbgstr_w(path), index);
     iconsdir=NULL;  /* Default is no icon */
+    static const WCHAR IconsDirW[] = {'I','c','o','n','s','D','i','r',0};
+    LPWSTR iconsdirW;
+    DWORD size = 0;
     /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Wine */
-    if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine", &hkey ))
+    if (RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine", &hkey ) == ERROR_SUCCESS &&
+        RegQueryValueExW(hkey, IconsDirW, 0, NULL, NULL, &size) == ERROR_SUCCESS)
     {
-        static const WCHAR IconsDirW[] = {'I','c','o','n','s','D','i','r',0};
-        LPWSTR iconsdirW;
-        DWORD size = 0;
+        iconsdirW = HeapAlloc(GetProcessHeap(), 0, size);
+        RegQueryValueExW(hkey, IconsDirW, 0, NULL, (LPBYTE)iconsdirW, &size);
 
-        if (!RegQueryValueExW(hkey, IconsDirW, 0, NULL, NULL, &size))
+        s = wine_get_unix_file_name(iconsdirW);
+        if (s)
+            iconsdir = s;
+        else
         {
-            iconsdirW = HeapAlloc(GetProcessHeap(), 0, size);
-            RegQueryValueExW(hkey, IconsDirW, 0, NULL, (LPBYTE)iconsdirW, &size);
+            int n = WideCharToMultiByte(CP_UNIXCP, 0, iconsdirW, -1, NULL, 0, NULL, NULL);
+            iconsdir = HeapAlloc(GetProcessHeap(), 0, n);
+            WideCharToMultiByte(CP_UNIXCP, 0, iconsdirW, -1, iconsdir, n, NULL, NULL);
+        }
+        HeapFree(GetProcessHeap(), 0, iconsdirW);
+    }
+    else
+    {
+        WCHAR path[MAX_PATH];
 
-            s = wine_get_unix_file_name(iconsdirW);
+        if (GetTempPathW(MAX_PATH, path))
+        {
+            s = wine_get_unix_file_name(path);
             if (s)
                 iconsdir = s;
-            else
-            {
-                int n = WideCharToMultiByte(CP_UNIXCP, 0, iconsdirW, -1, NULL, 0, NULL, NULL);
-                iconsdir = HeapAlloc(GetProcessHeap(), 0, n);
-                WideCharToMultiByte(CP_UNIXCP, 0, iconsdirW, -1, iconsdir, n, NULL, NULL);
-            }
-            HeapFree(GetProcessHeap(), 0, iconsdirW);
         }
-        else
-        {
-            WCHAR path[MAX_PATH];
-
-            if (GetTempPathW(MAX_PATH, path))
-            {
-                s = wine_get_unix_file_name(path);
-                if (s)
-                    iconsdir = s;
-            }
-        }
-        RegCloseKey( hkey );
     }
+    RegCloseKey( hkey );
+
     if (!iconsdir)
         return NULL;  /* No icon created */
     


More information about the wine-patches mailing list