[SHELL32] Fix property sheets that can't be closed due to failed init (#4709)
authorKyle Katarn <contact@kcsoftwares.com>
Mon, 19 Sep 2022 01:06:47 +0000 (03:06 +0200)
committerGitHub <noreply@github.com>
Mon, 19 Sep 2022 01:06:47 +0000 (04:06 +0300)
When a PropertySheet fails to init, that fact is being logged
and it shows an empty page, but it can't be closed.

Handle second failure properly by using FAILED_UNEXPECTEDLY macro.

CORE-18333

dll/win32/shell32/dialogs/fprop.cpp

index 3cab59b..b43ee56 100644 (file)
@@ -132,13 +132,20 @@ SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, PCUITEMID_CH
         {
             pFileDefExt->AddRef(); // CreateInstance returns object with 0 ref count
             hr = pFileDefExt->Initialize(pidlFolder, pDataObj, NULL);
-            if (SUCCEEDED(hr))
+            if (!FAILED_UNEXPECTEDLY(hr))
             {
                 hr = pFileDefExt->AddPages(AddPropSheetPageCallback, (LPARAM)&Header);
-                if (FAILED(hr))
+                if (FAILED_UNEXPECTEDLY(hr))
+                {
                     ERR("AddPages failed\n");
-            } else
+                    return FALSE;
+                }
+            }
+            else
+            {
                 ERR("Initialize failed\n");
+                return FALSE;
+            }
         }
 
         LoadPropSheetHandlers(wszPath, &Header, MAX_PROPERTY_SHEET_PAGE - 1, hpsxa, pDataObj);