17 lines
855 B
Diff
17 lines
855 B
Diff
--- a/singleapplication.cpp
|
|
+++ b/singleapplication.cpp
|
|
@@ -149,8 +149,11 @@
|
|
// Check if another instance can be started
|
|
if( allowSecondary ){
|
|
d->startSecondary();
|
|
- if( d->options & Mode::SecondaryNotification ){
|
|
- d->connectToPrimary( timeout, SingleApplicationPrivate::SecondaryInstance );
|
|
+ auto type = d->options & Mode::SecondaryNotification ? SingleApplicationPrivate::SecondaryInstance : SingleApplicationPrivate::InvalidConnection;
|
|
+ // If a connection to the primary instance cannot be established, become the primary instance.
|
|
+ if (!d->connectToPrimary(timeout, type)) {
|
|
+ d->initializeMemoryBlock();
|
|
+ d->startPrimary();
|
|
}
|
|
if( ! d->memory->unlock() ){
|
|
qDebug() << "SingleApplication: Unable to unlock memory after secondary start.";
|