aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItay Grudev <itay@grudev.com>2017-01-30 17:47:01 +0000
committerItay Grudev <itay@grudev.com>2017-01-30 17:47:01 +0000
commitcf347c47af84a03c35e7cf9315132cf790346736 (patch)
tree923fbecf915a6133484367b0f1168e2468556926
parentFix memory leak on SingleApplicationPrivate destruction (#23) (diff)
downloadsingleapplication-cf347c47af84a03c35e7cf9315132cf790346736.tar.xz
Refactored SingleApplicationPrivate destructor.
Deleted the separate cleanUp method as it’s not used from anywhere but the destructor.
-rw-r--r--singleapplication.cpp30
-rw-r--r--singleapplication_p.h1
2 files changed, 13 insertions, 18 deletions
diff --git a/singleapplication.cpp b/singleapplication.cpp
index bb50f49..34d9b1d 100644
--- a/singleapplication.cpp
+++ b/singleapplication.cpp
@@ -47,7 +47,19 @@ SingleApplicationPrivate::SingleApplicationPrivate( SingleApplication *q_ptr ) :
SingleApplicationPrivate::~SingleApplicationPrivate()
{
- cleanUp();
+ if( socket != nullptr ) {
+ socket->close();
+ delete socket;
+ }
+ memory->lock();
+ InstancesInfo* inst = (InstancesInfo*)memory->data();
+ if( server != nullptr ) {
+ server->close();
+ delete server;
+ inst->primary = false;
+ }
+ memory->unlock();
+ delete memory;
}
void SingleApplicationPrivate::genBlockServerName( int timeout )
@@ -230,22 +242,6 @@ void SingleApplicationPrivate::connectToPrimary( int msecs, char connectionType
QMutex SingleApplicationPrivate::sharedMemMutex;
#endif
-void SingleApplicationPrivate::cleanUp() {
- if( socket != nullptr ) {
- socket->close();
- delete socket;
- }
- memory->lock();
- InstancesInfo* inst = (InstancesInfo*)memory->data();
- if( server != nullptr ) {
- server->close();
- delete server;
- inst->primary = false;
- }
- memory->unlock();
- delete memory;
-}
-
/**
* @brief Executed when a connection has been made to the LocalServer
*/
diff --git a/singleapplication_p.h b/singleapplication_p.h
index 661fe9e..266cbea 100644
--- a/singleapplication_p.h
+++ b/singleapplication_p.h
@@ -55,7 +55,6 @@ public:
void startPrimary( bool resetMemory );
void startSecondary();
void connectToPrimary( int msecs, char connectionType );
- void cleanUp();
#ifdef Q_OS_UNIX
void crashHandler();