summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-06-03 18:02:46 +0200
committerChristian Stenger <christian.stenger@digia.com>2014-06-04 08:08:08 +0200
commit73e5c985e16dccd45fd42042710ee97942208603 (patch)
treedc6cd4c08e079597aee86cb5af36c4d2fecf5a53 /src/libs
parent82ca2e544feca93f422c5283782347e0869db2c8 (diff)
Initialize the client as early as possible.
Due do the fact that we can have several threads call to RemoteClient::instance() at the same time, some objects might get a not fully initialized object back. Most notable members of private class where initialized differently or not at all. Change-Id: I80fc4ad59583e3784c0e9f002e23d3df91f127b2 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/remoteclient.cpp11
-rw-r--r--src/libs/installer/remoteclient.h1
2 files changed, 10 insertions, 2 deletions
diff --git a/src/libs/installer/remoteclient.cpp b/src/libs/installer/remoteclient.cpp
index fed7ecc6c..8bab64999 100644
--- a/src/libs/installer/remoteclient.cpp
+++ b/src/libs/installer/remoteclient.cpp
@@ -49,6 +49,14 @@
namespace QInstaller {
+class RemoteClientGuard
+{
+public:
+ RemoteClient client;
+};
+Q_GLOBAL_STATIC(RemoteClientGuard, remoteClientGuard);
+static RemoteClientGuard *gGuard = remoteClientGuard();
+
RemoteClient::RemoteClient()
: d_ptr(new RemoteClientPrivate(this))
{
@@ -64,8 +72,7 @@ RemoteClient::~RemoteClient()
RemoteClient &RemoteClient::instance()
{
- static RemoteClient instance;
- return instance;
+ return gGuard->client;
}
QString RemoteClient::authorizationKey() const
diff --git a/src/libs/installer/remoteclient.h b/src/libs/installer/remoteclient.h
index 1ef8eba0b..84def80da 100644
--- a/src/libs/installer/remoteclient.h
+++ b/src/libs/installer/remoteclient.h
@@ -60,6 +60,7 @@ class INSTALLER_EXPORT RemoteClient : public QObject
Q_OBJECT
Q_DISABLE_COPY(RemoteClient)
Q_DECLARE_PRIVATE(RemoteClient)
+ friend class RemoteClientGuard;
public:
enum Mode {