ProjectExplorer: Simplify Kit settings file access

Check for existence of file in one place instead of once per file
we access.

Change-Id: Ie574d5e1e3e3aac97e239b57e94a58d9d3e7d626
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Tobias Hunger
2018-07-03 15:15:04 +02:00
parent 05fb67fee7
commit 72b1b3a55a

View File

@@ -126,9 +126,8 @@ void KitManager::restoreKits()
QList<Kit *> kitsToCheck;
// read all kits from SDK
QFileInfo kitFile(ICore::installerResourcePath() + KIT_FILENAME);
if (kitFile.exists()) {
KitList system = restoreKits(FileName(kitFile));
KitList system
= restoreKits(FileName::fromString(ICore::installerResourcePath() + KIT_FILENAME));
// make sure we mark these as autodetected and run additional setup logic
foreach (Kit *k, system.kits) {
k->setAutoDetected(true);
@@ -139,13 +138,9 @@ void KitManager::restoreKits()
// SDK kits are always considered to be up for validation since they might have been
// extended with additional information by creator in the meantime:
kitsToValidate = system.kits;
}
// read all kits from user file
KitList userKits;
FileName userSettingsFile(settingsFileName());
if (userSettingsFile.exists())
userKits = restoreKits(userSettingsFile);
KitList userKits = restoreKits(settingsFileName());
foreach (Kit *k, userKits.kits) {
if (k->isSdkProvided())
kitsToCheck.append(k);
@@ -316,6 +311,9 @@ KitManager::KitList KitManager::restoreKits(const FileName &fileName)
{
KitList result;
if (!fileName.exists())
return result;
PersistentSettingsReader reader;
if (!reader.load(fileName)) {
qWarning("Warning: Failed to read \"%s\", cannot restore kits!",