Skip to content

Commit

Permalink
fix: crash when quit application
Browse files Browse the repository at this point in the history
Change-Id: I347ddf47230bf7d04f9e3d7e0267a8bf4920a756
  • Loading branch information
zccrs committed Mar 13, 2018
1 parent 7d578e9 commit 13d22e3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/widgets/dapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,22 @@ bool DApplicationPrivate::setSingleInstanceBySemaphore(const QString &key)
singleInstance = tryAcquireSystemSemaphore(&ss);

if (singleInstance) {
QtConcurrent::run([] {
QtConcurrent::run([this] {
QPointer<DApplication> that = q_func();

while (ss.acquire() && singleInstance)
{
if (qApp->startingUp() || qApp->closingDown()) {
if (!that)
return;

if (that->startingUp() || that->closingDown()) {
break;
}

ss.release(1);

Q_EMIT qApp->newInstanceStarted();
if (that)
Q_EMIT that->newInstanceStarted();
}
});

Expand Down

0 comments on commit 13d22e3

Please sign in to comment.