mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-28 02:21:25 +00:00
code: Create mutexes to prevent Windows (un)installer from continuing
Might fix the problem where people uninstall StreamFX while they still have OBS Studio open with StreamFX loaded. InnoSetup appears to ignore this in /VERYSILENT, so this is an additional guard against that.
This commit is contained in:
parent
07182d2f89
commit
9d0233a740
2 changed files with 17 additions and 2 deletions
|
@ -136,7 +136,6 @@ MODULE_EXPORT void obs_module_unload(void)
|
|||
_streamfx_gfx_opengl.reset();
|
||||
}
|
||||
|
||||
|
||||
DLOG_INFO("Unloaded Version %s", STREAMFX_VERSION_STRING);
|
||||
} catch (std::exception const& ex) {
|
||||
DLOG_ERROR("Unexpected exception in function '%s': %s", __FUNCTION_NAME__, ex.what());
|
||||
|
|
|
@ -4,9 +4,25 @@
|
|||
|
||||
#include "warning-disable.hpp"
|
||||
#include <Windows.h>
|
||||
#include <mutex>
|
||||
#include "warning-enable.hpp"
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID)
|
||||
std::shared_ptr<void> local_mutex;
|
||||
std::shared_ptr<void> global_mutex;
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE, DWORD dwReason, LPVOID)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH) {
|
||||
// Prevent installer from progressing while StreamFX is still active.
|
||||
local_mutex = std::shared_ptr<void>(CreateMutexW(NULL, TRUE, L"Local\\StreamFX-Setup"), [](HANDLE p) {
|
||||
ReleaseMutex(p);
|
||||
CloseHandle(p);
|
||||
});
|
||||
global_mutex = std::shared_ptr<void>(CreateMutexW(NULL, TRUE, L"Global\\StreamFX-Setup"), [](HANDLE p) {
|
||||
ReleaseMutex(p);
|
||||
CloseHandle(p);
|
||||
});
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue