[EXPLORER-NEW]
[reactos.git] / dll / win32 / browseui / shellbrowser.cpp
index b45f116..c12143e 100644 (file)
@@ -897,28 +897,32 @@ HRESULT IEGetNameAndFlagsEx(LPITEMIDLIST pidl, SHGDNF uFlags, long param10,
     LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
 {
     CComPtr<IShellFolder>                   parentFolder;
-    LPITEMIDLIST                            childPIDL;
+    LPITEMIDLIST                            childPIDL = NULL;
     STRRET                                  L108;
     HRESULT                                 hResult;
 
     hResult = SHBindToFolderIDListParent(NULL, pidl, &IID_PPV_ARG(IShellFolder, &parentFolder), &childPIDL);
     if (FAILED(hResult))
-        return hResult;
+        goto cleanup;
 
     hResult = parentFolder->GetDisplayNameOf(childPIDL, uFlags, &L108);
     if (FAILED(hResult))
-        return hResult;
+        goto cleanup;
 
     StrRetToBufW(&L108, childPIDL, pszBuf, cchBuf);
     if (rgfInOut)
     {
         hResult = parentFolder->GetAttributesOf(1, const_cast<LPCITEMIDLIST *>(&childPIDL), rgfInOut);
         if (FAILED(hResult))
-            return hResult;
+            goto cleanup;
     }
 
-    ILFree(childPIDL);
-    return S_OK;
+    hResult = S_OK;
+
+cleanup:
+    if (childPIDL)
+        ILFree(childPIDL);
+    return hResult;
 }
 
 long IEGetNameAndFlags(LPITEMIDLIST pidl, SHGDNF uFlags, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
@@ -1074,11 +1078,17 @@ HRESULT CShellBrowser::BrowseToPath(IShellFolder *newShellFolder,
         HICON icSmall = ImageList_GetIcon(himlSmall, indexOpen, 0);
         HICON icLarge = ImageList_GetIcon(himlLarge, indexOpen, 0);
 
+        /* Hack to make it possible to release the old icons */
+        /* Something seems to go wrong with WM_SETICON */
+        HICON oldSmall = (HICON)SendMessage(WM_GETICON, ICON_SMALL, 0);
+        HICON oldLarge = (HICON)SendMessage(WM_GETICON, ICON_BIG,   0);
+
         SendMessage(WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icSmall));
         SendMessage(WM_SETICON, ICON_BIG,   reinterpret_cast<LPARAM>(icLarge));
-    }
 
-    // TODO: Update the window icon
+        DestroyIcon(oldSmall);
+        DestroyIcon(oldLarge);
+    }
 
     FireCommandStateChangeAll();
     hResult = UpdateForwardBackState();