summaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2014-12-10 10:27:42 +0100
committerNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2014-12-18 15:43:49 +0100
commit16becbd29c44e664904a7fb2d698f79fc08b2731 (patch)
treec049eab40a04468259559659bf5ebb10b7f74431 /src/app
parentfd6ba0e2a6fd9650d6a287ea0d55d5b97bedc8ad (diff)
downloadqt-creator-16becbd29c44e664904a7fb2d698f79fc08b2731.tar.gz
Plugin Tests: Create settings dir with QTemporaryDir
Create a clean and unique settings directory for "-test" runs if no settings path is provided explicitly. Change-Id: Ida2f5a74d42a5292963dd8d5d1f9dcddcdd24fd4 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Diffstat (limited to 'src/app')
-rw-r--r--src/app/main.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 301ec9a878..b137f9ad73 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -56,6 +56,7 @@
#include <QApplication>
#include <QMessageBox>
#include <QStandardPaths>
+#include <QTemporaryDir>
#ifdef ENABLE_QT_BREAKPAD
#include <qtsystemexceptionhandler.h>
@@ -338,10 +339,14 @@ int main(int argc, char **argv)
testOptionProvided = true;
}
}
+ QScopedPointer<QTemporaryDir> temporaryCleanSettingsDir;
if (settingsPath.isEmpty() && testOptionProvided) {
- settingsPath = QDir::tempPath() + QString::fromLatin1("/qtc-%1-test-settings")
- .arg(QLatin1String(Core::Constants::IDE_VERSION_LONG));
- settingsPath = QDir::cleanPath(settingsPath);
+ const QString settingsPathTemplate = QDir::cleanPath(QDir::tempPath()
+ + QString::fromLatin1("/qtc-test-settings-XXXXXX"));
+ temporaryCleanSettingsDir.reset(new QTemporaryDir(settingsPathTemplate));
+ if (!temporaryCleanSettingsDir->isValid())
+ return 1;
+ settingsPath = temporaryCleanSettingsDir->path();
}
if (!settingsPath.isEmpty())
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, settingsPath);