forked from qt-creator/qt-creator
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:
@@ -126,26 +126,21 @@ void KitManager::restoreKits()
|
|||||||
QList<Kit *> kitsToCheck;
|
QList<Kit *> kitsToCheck;
|
||||||
|
|
||||||
// read all kits from SDK
|
// read all kits from SDK
|
||||||
QFileInfo kitFile(ICore::installerResourcePath() + KIT_FILENAME);
|
KitList system
|
||||||
if (kitFile.exists()) {
|
= restoreKits(FileName::fromString(ICore::installerResourcePath() + KIT_FILENAME));
|
||||||
KitList system = restoreKits(FileName(kitFile));
|
// make sure we mark these as autodetected and run additional setup logic
|
||||||
// make sure we mark these as autodetected and run additional setup logic
|
foreach (Kit *k, system.kits) {
|
||||||
foreach (Kit *k, system.kits) {
|
k->setAutoDetected(true);
|
||||||
k->setAutoDetected(true);
|
k->setSdkProvided(true);
|
||||||
k->setSdkProvided(true);
|
k->makeSticky();
|
||||||
k->makeSticky();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// read all kits from user file
|
||||||
KitList userKits;
|
KitList userKits = restoreKits(settingsFileName());
|
||||||
FileName userSettingsFile(settingsFileName());
|
|
||||||
if (userSettingsFile.exists())
|
|
||||||
userKits = restoreKits(userSettingsFile);
|
|
||||||
foreach (Kit *k, userKits.kits) {
|
foreach (Kit *k, userKits.kits) {
|
||||||
if (k->isSdkProvided())
|
if (k->isSdkProvided())
|
||||||
kitsToCheck.append(k);
|
kitsToCheck.append(k);
|
||||||
@@ -316,6 +311,9 @@ KitManager::KitList KitManager::restoreKits(const FileName &fileName)
|
|||||||
{
|
{
|
||||||
KitList result;
|
KitList result;
|
||||||
|
|
||||||
|
if (!fileName.exists())
|
||||||
|
return result;
|
||||||
|
|
||||||
PersistentSettingsReader reader;
|
PersistentSettingsReader reader;
|
||||||
if (!reader.load(fileName)) {
|
if (!reader.load(fileName)) {
|
||||||
qWarning("Warning: Failed to read \"%s\", cannot restore kits!",
|
qWarning("Warning: Failed to read \"%s\", cannot restore kits!",
|
||||||
|
|||||||
Reference in New Issue
Block a user