From 1707df3da2ae288897ca60e21d7ec778ef77a184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Thu, 2 Feb 2017 16:10:06 +0100 Subject: [PATCH] comdlg32: Delay OleInitialize() until after file dialog window is created. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a problem exposed by commit f65e04770dc5748521a0de73814cea0b085bf3f8. Signed-off-by: Józef Kucia Signed-off-by: Alexandre Julliard --- dlls/comdlg32/filedlg.c | 12 ++++++------ dlls/comdlg32/filedlgbrowser.h | 1 + dlls/comdlg32/tests/filedlg.c | 1 - 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index d0d00b3b5d8..8a831636d7a 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -252,7 +252,6 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos) void *template; HRSRC hRes; HANDLE hDlgTmpl = 0; - HRESULT hr; /* test for missing functionality */ if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS) @@ -297,9 +296,6 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos) fodInfos->HookMsg.sharevistring = RegisterWindowMessageW(SHAREVISTRINGW); } - /* Some shell namespace extensions depend on COM being initialized. */ - hr = OleInitialize(NULL); - if (fodInfos->unicode) lRes = DialogBoxIndirectParamW(COMDLG32_hInstance, template, @@ -312,7 +308,7 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos) fodInfos->ofnInfos->hwndOwner, FileOpenDlgProc95, (LPARAM) fodInfos); - if (SUCCEEDED(hr)) + if (fodInfos->ole_initialized) OleUninitialize(); /* 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 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(...) */ SetPropA(hwnd, FileOpenDlgInfosStr, fodInfos); diff --git a/dlls/comdlg32/filedlgbrowser.h b/dlls/comdlg32/filedlgbrowser.h index 60f0e7e6126..6d108a952af 100644 --- a/dlls/comdlg32/filedlgbrowser.h +++ b/dlls/comdlg32/filedlgbrowser.h @@ -92,6 +92,7 @@ typedef struct UINT sharevistring; } HookMsg; + BOOL ole_initialized; } FileOpenDlgInfos; /*********************************************************************** diff --git a/dlls/comdlg32/tests/filedlg.c b/dlls/comdlg32/tests/filedlg.c index 89aa8fa77c1..ff973a7903d 100644 --- a/dlls/comdlg32/tests/filedlg.c +++ b/dlls/comdlg32/tests/filedlg.c @@ -1296,7 +1296,6 @@ static LRESULT CALLBACK hook_proc(int code, WPARAM wp, LPARAM lp) * after GetOpenFileA() is a file dialog window. Mark Vista+ * behavior as broken. */ hr = OleInitialize(NULL); - todo_wine_if(first_dlg) ok((first_dlg ? hr == S_OK : hr == S_FALSE) || broken(first_dlg && hr == S_FALSE), "OleInitialize() returned %#x (first dialog %#x)\n", hr, first_dlg);