Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-06-08 12:21:45 +0300
committerHannah von Reth <vonreth@kde.org>2021-06-08 12:36:15 +0300
commit818d165e31856dc0cb70982b55be30873a6111a4 (patch)
treec374d3880db93654e1b1d6b828490cf3dc65a262 /shell_integration
parentececf7b3a4c27cd10026442b4f31d2186478b609 (diff)
Fix deadlock introduced in 8fcc9adcc41f2b46a74b9c0d806d2f4721081f8a
Microsoft doc: Do not call GdiplusStartup or GdiplusShutdown in DllMain or in any function that is called by DllMain
Diffstat (limited to 'shell_integration')
-rw-r--r--shell_integration/windows/OCContextMenu/OCClientInterface.cpp9
-rw-r--r--shell_integration/windows/OCContextMenu/dllmain.cpp19
2 files changed, 14 insertions, 14 deletions
diff --git a/shell_integration/windows/OCContextMenu/OCClientInterface.cpp b/shell_integration/windows/OCContextMenu/OCClientInterface.cpp
index 841e51607..899b372e1 100644
--- a/shell_integration/windows/OCContextMenu/OCClientInterface.cpp
+++ b/shell_integration/windows/OCContextMenu/OCClientInterface.cpp
@@ -80,6 +80,10 @@ pair<wstring, nlohmann::json> parseV2(const wstring &data)
std::shared_ptr<HBITMAP> saveImage(const string &data)
{
+ ULONG_PTR gdiplusToken = 0;
+ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);
+
DWORD size = 2 * 1024;
std::vector<BYTE> buf(size, 0);
DWORD skipped;
@@ -99,7 +103,10 @@ std::shared_ptr<HBITMAP> saveImage(const string &data)
log(L"Failed to get HBITMAP", to_wstring(status));
return {};
}
- return std::shared_ptr<HBITMAP> { new HBITMAP(result), &DeleteObject };
+ return std::shared_ptr<HBITMAP> { new HBITMAP(result), [gdiplusToken](auto o) {
+ DeleteObject(o);
+ Gdiplus::GdiplusShutdown(gdiplusToken);
+ } };
}
}
diff --git a/shell_integration/windows/OCContextMenu/dllmain.cpp b/shell_integration/windows/OCContextMenu/dllmain.cpp
index 26de855af..9bc4c66af 100644
--- a/shell_integration/windows/OCContextMenu/dllmain.cpp
+++ b/shell_integration/windows/OCContextMenu/dllmain.cpp
@@ -30,26 +30,19 @@ long g_cDllRef = 0;
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
- static ULONG_PTR gdiplusToken = 0;
switch (dwReason) {
- case DLL_PROCESS_ATTACH: {
+ case DLL_PROCESS_ATTACH:
// Hold the instance of this DLL module, we will use it to get the
// path of the DLL to register the component.
g_hInst = hModule;
DisableThreadLibraryCalls(hModule);
-
- Gdiplus::GdiplusStartupInput gdiplusStartupInput;
- Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+ break;
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
break;
}
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- break;
- case DLL_PROCESS_DETACH:
- Gdiplus::GdiplusShutdown(gdiplusToken);
- break;
- }
- return TRUE;
+ return TRUE;
}
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)