forked from qt-creator/qt-creator
Protect the access to IDevice::sshParameters()
May be called in non-gui threads while it may be changed from settings widget at the same time. Change-Id: I2897fc2e54336b9043213411cb620896bbecde86 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QReadWriteLock>
|
||||
#include <QString>
|
||||
#include <QUuid>
|
||||
|
||||
@@ -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<Origin>(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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user