diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index 5f7e384f2fc..7f1aa6c4482 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #include @@ -151,6 +152,7 @@ public: OsType osType = OsTypeOther; int version = 0; // This is used by devices that have been added by the SDK. + QReadWriteLock lock; // Currently used to protect sshParameters only QSsh::SshConnectionParameters sshParameters; PortList freePorts; FilePath debugServerPath; @@ -636,6 +638,7 @@ void IDevice::fromMap(const QVariantMap &map) d->id = newId(); d->origin = static_cast(map.value(QLatin1String(OriginKey), ManuallyAdded).toInt()); + QWriteLocker locker(&d->lock); d->sshParameters.setHost(map.value(QLatin1String(HostKey)).toString()); d->sshParameters.setPort(map.value(QLatin1String(SshPortKey), 22).toInt()); d->sshParameters.setUserName(map.value(QLatin1String(UserNameKey)).toString()); @@ -680,6 +683,7 @@ QVariantMap IDevice::toMap() const map.insert(QLatin1String(IdKey), d->id.toSetting()); map.insert(QLatin1String(OriginKey), d->origin); + QReadLocker locker(&d->lock); map.insert(QLatin1String(MachineTypeKey), d->machineType); map.insert(QLatin1String(HostKey), d->sshParameters.host()); map.insert(QLatin1String(SshPortKey), d->sshParameters.port()); @@ -730,11 +734,13 @@ QString IDevice::deviceStateToString() const QSsh::SshConnectionParameters IDevice::sshParameters() const { + QReadLocker locker(&d->lock); return d->sshParameters; } void IDevice::setSshParameters(const QSsh::SshConnectionParameters &sshParameters) { + QWriteLocker locker(&d->lock); d->sshParameters = sshParameters; } @@ -742,6 +748,7 @@ QUrl IDevice::toolControlChannel(const ControlChannelHint &) const { QUrl url; url.setScheme(Utils::urlTcpScheme()); + QReadLocker locker(&d->lock); url.setHost(d->sshParameters.host()); return url; }