Skip to content

Commit

Permalink
MusPlay: Single-application fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohlstand committed Aug 18, 2019
1 parent 1b6f733 commit 3e8007b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions examples/MusPlay-Qt/SingleApplication/singleapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,22 @@ SingleApplication::SingleApplication(QStringList &args) :
_shouldContinue = false; // By default this is not the main process

socket = new QUdpSocket();
server = NULL;
server = nullptr;
QString isServerRuns;

bool isRunning=false;
m_sema.acquire();//Avoid races
if(m_shmem.attach()) //Detect shared memory copy
{
isRunning = true;
}
else

if(!m_shmem.create(1))//Detect shared memory copy
{
m_shmem.create(1);
isRunning = false;
m_shmem.attach();
m_shmem.detach();
if(!m_shmem.create(1))
{
isRunning = true;
if(!m_shmem.attach())
qWarning() << "Can't re-attach existing shared memory!";
}
}

//Force run second copy of application
Expand Down

0 comments on commit 3e8007b

Please sign in to comment.