forked from qt-creator/qt-creator
Beautifier: Fix ArtisticStyleSettings
Done-by: Eike Ziller <eike.ziller@digia.com> Change-Id: I6dd22f9519d4b14345d27ed2128559efac2cb697 Reviewed-by: Eike Ziller <eike.ziller@digia.com> Reviewed-by: Robert Loehning <robert.loehning@digia.com>
This commit is contained in:
committed by
Eike Ziller
parent
388462d178
commit
7c632f65f7
@@ -74,17 +74,18 @@ void ArtisticStyleSettings::updateVersion()
|
||||
if (m_versionFuture.isRunning())
|
||||
m_versionFuture.cancel();
|
||||
|
||||
m_versionFuture = QtConcurrent::run(this, &ArtisticStyleSettings::helperUpdateVersion);
|
||||
m_versionFuture = QtConcurrent::run(&ArtisticStyleSettings::helperUpdateVersion, this);
|
||||
m_versionWatcher.setFuture(m_versionFuture);
|
||||
}
|
||||
|
||||
int ArtisticStyleSettings::helperUpdateVersion() const
|
||||
void ArtisticStyleSettings::helperUpdateVersion(QFutureInterface<int> &future)
|
||||
{
|
||||
QProcess process;
|
||||
process.start(command(), QStringList() << QLatin1String("--version"));
|
||||
if (!process.waitForFinished()) {
|
||||
process.kill();
|
||||
return 0;
|
||||
future.reportResult(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// The version in Artistic Style is printed like "Artistic Style Version 2.04"
|
||||
@@ -93,9 +94,11 @@ int ArtisticStyleSettings::helperUpdateVersion() const
|
||||
if (rx.indexIn(version) != -1) {
|
||||
const int major = rx.cap(1).toInt() * 100;
|
||||
const int minor = rx.cap(2).toInt();
|
||||
return major + minor;
|
||||
future.reportResult(major + minor);
|
||||
return;
|
||||
}
|
||||
return 0;
|
||||
future.reportResult(0);
|
||||
return;
|
||||
}
|
||||
|
||||
void ArtisticStyleSettings::helperSetVersion()
|
||||
|
||||
@@ -75,7 +75,7 @@ private slots:
|
||||
private:
|
||||
QFuture<int> m_versionFuture;
|
||||
QFutureWatcher<int> m_versionWatcher;
|
||||
int helperUpdateVersion() const;
|
||||
void helperUpdateVersion(QFutureInterface<int> &future);
|
||||
};
|
||||
|
||||
} // namespace ArtisticStyle
|
||||
|
||||
Reference in New Issue
Block a user