mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-19 04:09:55 -06:00
Attempt to get rid of leftover QSharedMemory instance after crash
This commit is contained in:
@ -66,12 +66,25 @@ void IPCInit()
|
|||||||
|
|
||||||
IPCBuffer = new QSharedMemory("melonIPC");
|
IPCBuffer = new QSharedMemory("melonIPC");
|
||||||
|
|
||||||
|
#if !defined(Q_OS_WINDOWS)
|
||||||
|
// QSharedMemory instances can be left over from crashed processes on UNIX platforms.
|
||||||
|
// To prevent melonDS thinking there's another instance, we attach and then immediately detach from the
|
||||||
|
// shared memory. If no other process was actually using it, it'll be destroyed and we'll have a clean
|
||||||
|
// shared memory buffer after creating it again below.
|
||||||
|
if (IPCBuffer->attach())
|
||||||
|
{
|
||||||
|
IPCBuffer->detach();
|
||||||
|
delete IPCBuffer;
|
||||||
|
IPCBuffer = new QSharedMemory("melonIPC");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!IPCBuffer->attach())
|
if (!IPCBuffer->attach())
|
||||||
{
|
{
|
||||||
Log(LogLevel::Info, "IPC sharedmem doesn't exist. creating\n");
|
Log(LogLevel::Info, "IPC sharedmem doesn't exist. creating\n");
|
||||||
if (!IPCBuffer->create(1024))
|
if (!IPCBuffer->create(1024))
|
||||||
{
|
{
|
||||||
Log(LogLevel::Error, "IPC sharedmem create failed :(\n");
|
Log(LogLevel::Error, "IPC sharedmem create failed: %s\n", IPCBuffer->errorString().toStdString().c_str());
|
||||||
delete IPCBuffer;
|
delete IPCBuffer;
|
||||||
IPCBuffer = nullptr;
|
IPCBuffer = nullptr;
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user