https://git.reactos.org/?p=reactos.git;a=commitdiff;h=afc130ff3f5b089c02706…
commit afc130ff3f5b089c0270686d1b76b3cb08133e38
Author: Whindmar Saksit <whindsaks(a)proton.me>
AuthorDate: Fri Jan 3 20:16:56 2025 +0100
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri Jan 3 20:16:56 2025 +0100
[SHELL32] Pump COM messages while initializing propsheet from IDataObject (#7571)
CORE-19933
---
dll/win32/shell32/dialogs/item_prop.cpp | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/dll/win32/shell32/dialogs/item_prop.cpp
b/dll/win32/shell32/dialogs/item_prop.cpp
index 90160a8062e..bcc6473144d 100644
--- a/dll/win32/shell32/dialogs/item_prop.cpp
+++ b/dll/win32/shell32/dialogs/item_prop.cpp
@@ -27,7 +27,7 @@ struct ShellPropSheetDialog
HKEY *hKeys, UINT *cKeys);
static HRESULT Show(const CLSID *pClsidDefault, IDataObject *pDO,
- PFNINITIALIZE InitFunc, LPCWSTR InitString)
+ PFNINITIALIZE InitFunc, LPCWSTR InitString, HANDLE hEvent =
NULL)
{
HRESULT hr;
CRegKeyHandleArray keys;
@@ -36,6 +36,8 @@ struct ShellPropSheetDialog
WCHAR szCaption[MAX_PATH], *pszCaption = NULL;
if (SUCCEEDED(SHELL_GetCaptionFromDataObject(pDO, szCaption,
_countof(szCaption))))
pszCaption = szCaption;
+ if (hEvent)
+ SetEvent(hEvent);
hr = SHOpenPropSheetW(pszCaption, keys, keys, pClsidDefault, pDO, NULL, NULL) ?
S_OK : E_FAIL;
return hr;
}
@@ -47,6 +49,7 @@ struct ShellPropSheetDialog
CLSID ClsidDefault;
const CLSID *pClsidDefault;
IStream *pObjStream;
+ HANDLE hEvent;
};
static void FreeData(DATA *pData)
@@ -74,6 +77,7 @@ struct ShellPropSheetDialog
pData->ClsidDefault = *pClsidDefault;
pData->pClsidDefault = &pData->ClsidDefault;
}
+ HANDLE hEvent = pData->hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
HRESULT hr = S_OK;
if (pDO)
@@ -86,8 +90,21 @@ struct ShellPropSheetDialog
pData->pObjStream->Release();
hr = E_FAIL;
}
- if (FAILED(hr))
+
+ if (SUCCEEDED(hr))
+ {
+ if (hEvent)
+ {
+ DWORD index;
+ // Pump COM messages until InitFunc is done (for CORE-19933)
+ CoWaitForMultipleHandles(COWAIT_DEFAULT, INFINITE, 1, &hEvent,
&index);
+ CloseHandle(hEvent);
+ }
+ }
+ else
+ {
FreeData(pData);
+ }
return hr;
}
@@ -97,7 +114,7 @@ struct ShellPropSheetDialog
CComPtr<IDataObject> pDO;
if (pData->pObjStream)
CoGetInterfaceAndReleaseStream(pData->pObjStream, IID_PPV_ARG(IDataObject,
&pDO));
- Show(pData->pClsidDefault, pDO, pData->InitFunc, pData->InitString);
+ Show(pData->pClsidDefault, pDO, pData->InitFunc, pData->InitString,
pData->hEvent);
FreeData(pData);
return 0;
}