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:
Robert Loehning
2014-05-30 12:02:06 +02:00
committed by Eike Ziller
parent 388462d178
commit 7c632f65f7
2 changed files with 9 additions and 6 deletions

View File

@@ -74,17 +74,18 @@ void ArtisticStyleSettings::updateVersion()
if (m_versionFuture.isRunning()) if (m_versionFuture.isRunning())
m_versionFuture.cancel(); m_versionFuture.cancel();
m_versionFuture = QtConcurrent::run(this, &ArtisticStyleSettings::helperUpdateVersion); m_versionFuture = QtConcurrent::run(&ArtisticStyleSettings::helperUpdateVersion, this);
m_versionWatcher.setFuture(m_versionFuture); m_versionWatcher.setFuture(m_versionFuture);
} }
int ArtisticStyleSettings::helperUpdateVersion() const void ArtisticStyleSettings::helperUpdateVersion(QFutureInterface<int> &future)
{ {
QProcess process; QProcess process;
process.start(command(), QStringList() << QLatin1String("--version")); process.start(command(), QStringList() << QLatin1String("--version"));
if (!process.waitForFinished()) { if (!process.waitForFinished()) {
process.kill(); process.kill();
return 0; future.reportResult(0);
return;
} }
// The version in Artistic Style is printed like "Artistic Style Version 2.04" // 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) { if (rx.indexIn(version) != -1) {
const int major = rx.cap(1).toInt() * 100; const int major = rx.cap(1).toInt() * 100;
const int minor = rx.cap(2).toInt(); const int minor = rx.cap(2).toInt();
return major + minor; future.reportResult(major + minor);
return;
} }
return 0; future.reportResult(0);
return;
} }
void ArtisticStyleSettings::helperSetVersion() void ArtisticStyleSettings::helperSetVersion()

View File

@@ -75,7 +75,7 @@ private slots:
private: private:
QFuture<int> m_versionFuture; QFuture<int> m_versionFuture;
QFutureWatcher<int> m_versionWatcher; QFutureWatcher<int> m_versionWatcher;
int helperUpdateVersion() const; void helperUpdateVersion(QFutureInterface<int> &future);
}; };
} // namespace ArtisticStyle } // namespace ArtisticStyle