mirror of
https://github.com/itay-grudev/SingleApplication.git
synced 2025-01-14 16:32:06 +08:00
Check the primary connection and assume primary if no response is found.
This guards against the case of stale shared memory that can happen when the primary application crashes or is forcefully killed. Issue #190 Signed-off-by: Adam Treat <treat.adam@gmail.com>
This commit is contained in:
parent
494772e98c
commit
21bdef01ed
@ -137,6 +137,13 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda
|
||||
}
|
||||
}
|
||||
|
||||
// Check to ensure the primary process really does exist by sending a message and if it does not
|
||||
// then assume primary status
|
||||
if ( inst->primary != false && !d->connectToPrimary( timeout, SingleApplicationPrivate::SecondaryInstance )) {
|
||||
qDebug() << "SingleApplication: Cannot communicate with primary so assuming primary status.";
|
||||
inst->primary = false;
|
||||
}
|
||||
|
||||
if( inst->primary == false ){
|
||||
d->startPrimary();
|
||||
if( ! d->memory->unlock() ){
|
||||
|
Loading…
Reference in New Issue
Block a user