aboutsummaryrefslogtreecommitdiff
path: root/singleapplication.cpp
diff options
context:
space:
mode:
authorItay Grudev <itay@grudev.com>2017-04-23 14:31:32 +0300
committerItay Grudev <itay@grudev.com>2017-04-23 14:31:32 +0300
commitc2a6faca68379e02dead9d6303e29fe1b9960994 (patch)
treeb9624bba40877a23bc1ddc34282ad941245da30c /singleapplication.cpp
parentFixed compilation error: cannot convert wchar_t* to LPSTR {aka char*} (#29) (diff)
downloadsingleapplication-c2a6faca68379e02dead9d6303e29fe1b9960994.tar.xz
Removed QMutex for thread safe behaviour and support for multiple SingleApplication instances
Problem raised by @retmas in #24
Diffstat (limited to 'singleapplication.cpp')
-rw-r--r--singleapplication.cpp17
1 files changed, 1 insertions, 16 deletions
diff --git a/singleapplication.cpp b/singleapplication.cpp
index 31e3f0f..54c2c2d 100644
--- a/singleapplication.cpp
+++ b/singleapplication.cpp
@@ -220,15 +220,6 @@ void SingleApplicationPrivate::connectToPrimary( int msecs, char connectionType
#ifdef Q_OS_UNIX
void SingleApplicationPrivate::crashHandler()
{
- // This guarantees the program will work even with multiple
- // instances of SingleApplication in different threads.
- // Which in my opinion is idiotic, but lets handle that too.
- {
- sharedMemMutex.lock();
- sharedMem.append( this );
- sharedMemMutex.unlock();
- }
-
// Handle any further termination signals to ensure the
// QSharedMemory block is deleted even if the process crashes
signal( SIGHUP, SingleApplicationPrivate::terminate ); // 1
@@ -249,15 +240,9 @@ void SingleApplicationPrivate::connectToPrimary( int msecs, char connectionType
void SingleApplicationPrivate::terminate( int signum )
{
- while( ! sharedMem.empty() ) {
- delete sharedMem.back();
- sharedMem.pop_back();
- }
+ delete ((SingleApplication*)QApplication::instance())->d_ptr;
::exit( 128 + signum );
}
-
- QList<SingleApplicationPrivate*> SingleApplicationPrivate::sharedMem;
- QMutex SingleApplicationPrivate::sharedMemMutex;
#endif
/**