summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/remoteclient.cpp
diff options
context:
space:
mode:
authorFrerich Raabe <raabe@froglogic.com>2015-11-23 14:37:29 +0100
committerKarsten Heimrich <karsten.heimrich@theqtcompany.com>2015-12-08 13:06:08 +0000
commit85ce71449b9ec80f636054ef447a21716cf5ab7a (patch)
tree5e7c4560b906c1d8871120433cb991d74c806afb /src/libs/installer/remoteclient.cpp
parentf36065651341dcde8296135e020de9279f90f3ec (diff)
Fixed occasional crash on Windows when terminating installer
The static RemoteClient object (defined in RemoteClient::instance()) which gets destroyed at the very end of the process lifetime would -- as part of its constructor -- execute the RemoteClientPrivate destructor. The RemoteClientPrivate destructor did non-trivial work though, trying to shut down the connection which involves accessing the LocalServer instance. Executing this code at the very end of the process lifetime would sometimes cause a crash on Windows with a back trace into the QMutex guts. Let's fix this by getting more control over the destruction order; the RemoteClient instance is no longer a static object but allocated dynamically. Callers can explicitly call 'destroy' to dispose of the instance as part of their shutdown routine. Change-Id: Ie6773ccc0276ad6285919e57e9ed190bab02be3f Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/remoteclient.cpp')
-rw-r--r--src/libs/installer/remoteclient.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libs/installer/remoteclient.cpp b/src/libs/installer/remoteclient.cpp
index bac96573b..3422cb468 100644
--- a/src/libs/installer/remoteclient.cpp
+++ b/src/libs/installer/remoteclient.cpp
@@ -37,6 +37,8 @@
namespace QInstaller {
+RemoteClient *RemoteClient::s_instance = 0;
+
RemoteClient::RemoteClient()
: d_ptr(new RemoteClientPrivate(this))
{
@@ -48,8 +50,9 @@ RemoteClient::~RemoteClient()
RemoteClient &RemoteClient::instance()
{
- static RemoteClient instance;
- return instance;
+ if (!s_instance)
+ s_instance = new RemoteClient;
+ return *s_instance;
}
QString RemoteClient::socketName() const
@@ -82,6 +85,12 @@ void RemoteClient::shutdown()
d_ptr.reset(new RemoteClientPrivate(this));
}
+void RemoteClient::destroy()
+{
+ delete s_instance;
+ s_instance = 0;
+}
+
bool RemoteClient::isActive() const
{
Q_D(const RemoteClient);