comdlg32: Delay OleInitialize() until after file dialog window is created.

This fixes a problem exposed by commit
f65e04770d.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2017-02-02 16:10:06 +01:00 committed by Alexandre Julliard
parent 5dda6495eb
commit 1707df3da2
3 changed files with 7 additions and 7 deletions

View File

@ -252,7 +252,6 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
void *template; void *template;
HRSRC hRes; HRSRC hRes;
HANDLE hDlgTmpl = 0; HANDLE hDlgTmpl = 0;
HRESULT hr;
/* test for missing functionality */ /* test for missing functionality */
if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS) if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS)
@ -297,9 +296,6 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
fodInfos->HookMsg.sharevistring = RegisterWindowMessageW(SHAREVISTRINGW); fodInfos->HookMsg.sharevistring = RegisterWindowMessageW(SHAREVISTRINGW);
} }
/* Some shell namespace extensions depend on COM being initialized. */
hr = OleInitialize(NULL);
if (fodInfos->unicode) if (fodInfos->unicode)
lRes = DialogBoxIndirectParamW(COMDLG32_hInstance, lRes = DialogBoxIndirectParamW(COMDLG32_hInstance,
template, template,
@ -312,7 +308,7 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
fodInfos->ofnInfos->hwndOwner, fodInfos->ofnInfos->hwndOwner,
FileOpenDlgProc95, FileOpenDlgProc95,
(LPARAM) fodInfos); (LPARAM) fodInfos);
if (SUCCEEDED(hr)) if (fodInfos->ole_initialized)
OleUninitialize(); OleUninitialize();
/* Unable to create the dialog */ /* Unable to create the dialog */
@ -1262,7 +1258,11 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
int gripx = GetSystemMetrics( SM_CYHSCROLL); int gripx = GetSystemMetrics( SM_CYHSCROLL);
int gripy = GetSystemMetrics( SM_CYVSCROLL); int gripy = GetSystemMetrics( SM_CYVSCROLL);
/* Adds the FileOpenDlgInfos in the property list of the dialog /* Some shell namespace extensions depend on COM being initialized. */
if (SUCCEEDED(OleInitialize(NULL)))
fodInfos->ole_initialized = TRUE;
/* Adds the FileOpenDlgInfos in the property list of the dialog
so it will be easily accessible through a GetPropA(...) */ so it will be easily accessible through a GetPropA(...) */
SetPropA(hwnd, FileOpenDlgInfosStr, fodInfos); SetPropA(hwnd, FileOpenDlgInfosStr, fodInfos);

View File

@ -92,6 +92,7 @@ typedef struct
UINT sharevistring; UINT sharevistring;
} HookMsg; } HookMsg;
BOOL ole_initialized;
} FileOpenDlgInfos; } FileOpenDlgInfos;
/*********************************************************************** /***********************************************************************

View File

@ -1296,7 +1296,6 @@ static LRESULT CALLBACK hook_proc(int code, WPARAM wp, LPARAM lp)
* after GetOpenFileA() is a file dialog window. Mark Vista+ * after GetOpenFileA() is a file dialog window. Mark Vista+
* behavior as broken. */ * behavior as broken. */
hr = OleInitialize(NULL); hr = OleInitialize(NULL);
todo_wine_if(first_dlg)
ok((first_dlg ? hr == S_OK : hr == S_FALSE) ok((first_dlg ? hr == S_OK : hr == S_FALSE)
|| broken(first_dlg && hr == S_FALSE), || broken(first_dlg && hr == S_FALSE),
"OleInitialize() returned %#x (first dialog %#x)\n", hr, first_dlg); "OleInitialize() returned %#x (first dialog %#x)\n", hr, first_dlg);