[FILEBROWSER]
authorDavid Quintana <gigaherz@gmail.com>
Tue, 7 Oct 2014 14:40:33 +0000 (14:40 +0000)
committerDavid Quintana <gigaherz@gmail.com>
Tue, 7 Oct 2014 14:40:33 +0000 (14:40 +0000)
* Always open separate.

[BROWSEUI]
* Use the threadref IUnknown for reference counting in the browser threads.

svn path=/branches/shell-experiments/; revision=64578

base/shell/filebrowser/filebrowser.c
dll/win32/browseui/desktopipc.cpp
dll/win32/browseui/shellbrowser.cpp

index c8a8228..ee5f59e 100644 (file)
 #include <shlwapi_undoc.h>
 #include <stdio.h>
 
-typedef HRESULT (WINAPI *SH_OPEN_NEW_FRAME)(LPITEMIDLIST pidl, IUnknown *paramC, long param10, long param14);
-
 int _tmain(int argc, _TCHAR* argv[])
 {
     EXPLORER_CMDLINE_PARSE_RESULTS parseResults = { 0 };
 
     if (SHExplorerParseCmdLine(&parseResults))
+    {
+        parseResults.dwFlags |= SH_EXPLORER_CMDLINE_FLAG_SEPARATE;
         return SHCreateFromDesktop(&parseResults);
+    }
 
     return 0;
 }
index 6d405b3..aec6a95 100644 (file)
@@ -450,15 +450,21 @@ extern "C" HRESULT WINAPI SHOpenFolderWindow(PIE_THREAD_PARAM_BLOCK parameters)
     HANDLE                                  threadHandle;
     DWORD                                   threadID;
 
-    DbgPrint("SHOpenFolderWindow\n");
+    WCHAR debugStr[MAX_PATH + 1];
+    SHGetPathFromIDListW(parameters->directoryPIDL, debugStr);
 
-    threadHandle = CreateThread(NULL, 0x10000, BrowserThreadProc, parameters, 0, &threadID);
+    DbgPrint("SHOpenFolderWindow %p(%S)\n", parameters->directoryPIDL, debugStr);
+
+    PIE_THREAD_PARAM_BLOCK paramsCopy = SHCloneIETHREADPARAM(parameters);
+
+    SHGetInstanceExplorer(&(paramsCopy->offsetF8));
+    threadHandle = CreateThread(NULL, 0x10000, BrowserThreadProc, paramsCopy, 0, &threadID);
     if (threadHandle != NULL)
     {
         CloseHandle(threadHandle);
         return S_OK;
     }
-    SHDestroyIETHREADPARAM(parameters);
+    SHDestroyIETHREADPARAM(paramsCopy);
     return E_FAIL;
 }
 
@@ -485,8 +491,12 @@ extern "C" HRESULT WINAPI SHOpenNewFrame(LPITEMIDLIST pidl, IUnknown *paramC, lo
         parameters->offset10 = param10;
     parameters->directoryPIDL = pidl;
     parameters->dwFlags = dwFlags;
-
-    return SHOpenFolderWindow(parameters);
+    
+    HRESULT hr = SHOpenFolderWindow(parameters);
+    
+    SHDestroyIETHREADPARAM(parameters);
+    
+    return hr;
 }
 
 /*************************************************************************
index 347e0ba..a933009 100644 (file)
@@ -3399,6 +3399,9 @@ static HRESULT ExplorerMessageLoop(IEThreadParamBlock * parameters)
     HRESULT                   hResult;
     MSG Msg;
     BOOL Ret;
+
+    // Tell the thread ref we are using it.
+    parameters->offsetF8->AddRef();
     
     ATLTRY(theCabinet = new CComObject<CShellBrowser>);
     if (theCabinet == NULL)
@@ -3440,6 +3443,9 @@ static HRESULT ExplorerMessageLoop(IEThreadParamBlock * parameters)
 
     theCabinet.Detach();
 
+    // Tell the thread ref we are not using it anymore.
+    parameters->offsetF8->Release();
+
     return hResult;
 }
 
@@ -3454,5 +3460,7 @@ DWORD WINAPI BrowserThreadProc(LPVOID lpThreadParameter)
 
     OleUninitialize();
 
+    SHDestroyIETHREADPARAM(parameters);
+
     return hr;
 }