forked from qt-creator/qt-creator
Do not construct settings/resource paths from QSettings object
These paths are controlled by ICore. Add ICore::installerResourcePath() to replace constructions with settings(SystemScope) Replace constructions with settings()->fileName() by usage of ICore::userResourcePath(). Change-Id: I5a9fa9d09f2563c39dc5d11a4586da825c62f9ac Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -127,8 +127,7 @@ namespace {
|
||||
|
||||
static QString sdkSettingsFileName()
|
||||
{
|
||||
return QFileInfo(Core::ICore::settings(QSettings::SystemScope)->fileName()).absolutePath()
|
||||
+ QLatin1String("/qtcreator/android.xml");
|
||||
return Core::ICore::installerResourcePath() + "/android.xml";
|
||||
}
|
||||
|
||||
static bool is32BitUserSpace()
|
||||
|
@@ -47,19 +47,13 @@ namespace Internal {
|
||||
const char dataKeyC[] = "GdbServerProvider.";
|
||||
const char countKeyC[] = "GdbServerProvider.Count";
|
||||
const char fileVersionKeyC[] = "Version";
|
||||
const char fileNameKeyC[] = "/qtcreator/gdbserverproviders.xml";
|
||||
|
||||
static Utils::FileName settingsFileName(const QString &path)
|
||||
{
|
||||
const QFileInfo settingsLocation(Core::ICore::settings()->fileName());
|
||||
return Utils::FileName::fromString(settingsLocation.absolutePath() + path);
|
||||
}
|
||||
const char fileNameKeyC[] = "/gdbserverproviders.xml";
|
||||
|
||||
static GdbServerProviderManager *m_instance = 0;
|
||||
|
||||
GdbServerProviderManager::GdbServerProviderManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_configFile(settingsFileName(QLatin1String(fileNameKeyC)))
|
||||
, m_configFile(Utils::FileName::fromString(Core::ICore::userResourcePath() + fileNameKeyC))
|
||||
, m_factories({new DefaultGdbServerProviderFactory,
|
||||
new OpenOcdGdbServerProviderFactory,
|
||||
new StLinkUtilGdbServerProviderFactory})
|
||||
|
@@ -46,7 +46,7 @@ const char CMAKETOOL_COUNT_KEY[] = "CMakeTools.Count";
|
||||
const char CMAKETOOL_DEFAULT_KEY[] = "CMakeTools.Default";
|
||||
const char CMAKETOOL_DATA_KEY[] = "CMakeTools.";
|
||||
const char CMAKETOOL_FILE_VERSION_KEY[] = "Version";
|
||||
const char CMAKETOOL_FILENAME[] = "/qtcreator/cmaketools.xml";
|
||||
const char CMAKETOOL_FILENAME[] = "/cmaketools.xml";
|
||||
|
||||
class CMakeToolManagerPrivate
|
||||
{
|
||||
@@ -71,8 +71,7 @@ static void addCMakeTool(CMakeTool *item)
|
||||
|
||||
static FileName userSettingsFileName()
|
||||
{
|
||||
QFileInfo settingsLocation(ICore::settings()->fileName());
|
||||
return FileName::fromString(settingsLocation.absolutePath() + QLatin1String(CMAKETOOL_FILENAME));
|
||||
return FileName::fromString(ICore::userResourcePath() + CMAKETOOL_FILENAME);
|
||||
}
|
||||
|
||||
static QList<CMakeTool *> readCMakeTools(const FileName &fileName, Core::Id *defaultId, bool fromSDK)
|
||||
@@ -325,9 +324,8 @@ void CMakeToolManager::restoreCMakeTools()
|
||||
{
|
||||
Core::Id defaultId;
|
||||
|
||||
QFileInfo systemSettingsFile(ICore::settings(QSettings::SystemScope)->fileName());
|
||||
FileName sdkSettingsFile = FileName::fromString(systemSettingsFile.absolutePath()
|
||||
+ QLatin1String(CMAKETOOL_FILENAME));
|
||||
FileName sdkSettingsFile = FileName::fromString(ICore::installerResourcePath()
|
||||
+ CMAKETOOL_FILENAME);
|
||||
|
||||
QList<CMakeTool *> toolsToRegister = readCMakeTools(sdkSettingsFile, &defaultId, true);
|
||||
|
||||
|
@@ -421,6 +421,12 @@ QString ICore::userResourcePath()
|
||||
return urp;
|
||||
}
|
||||
|
||||
QString ICore::installerResourcePath()
|
||||
{
|
||||
return QFileInfo(settings(QSettings::SystemScope)->fileName()).path() + '/'
|
||||
+ Constants::IDE_ID;
|
||||
}
|
||||
|
||||
QString ICore::documentationPath()
|
||||
{
|
||||
return QDir::cleanPath(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DOC_PATH);
|
||||
|
@@ -94,6 +94,7 @@ public:
|
||||
|
||||
static QString resourcePath();
|
||||
static QString userResourcePath();
|
||||
static QString installerResourcePath();
|
||||
static QString documentationPath();
|
||||
static QString libexecPath();
|
||||
|
||||
|
@@ -71,9 +71,9 @@ namespace Internal {
|
||||
|
||||
const char DEBUGGER_COUNT_KEY[] = "DebuggerItem.Count";
|
||||
const char DEBUGGER_DATA_KEY[] = "DebuggerItem.";
|
||||
const char DEBUGGER_LEGACY_FILENAME[] = "/qtcreator/profiles.xml";
|
||||
const char DEBUGGER_LEGACY_FILENAME[] = "/profiles.xml";
|
||||
const char DEBUGGER_FILE_VERSION_KEY[] = "Version";
|
||||
const char DEBUGGER_FILENAME[] = "/qtcreator/debuggers.xml";
|
||||
const char DEBUGGER_FILENAME[] = "/debuggers.xml";
|
||||
const char debuggingToolsWikiLinkC[] = "http://wiki.qt.io/Qt_Creator_Windows_Debugging";
|
||||
|
||||
class DebuggerItemModel;
|
||||
@@ -821,8 +821,7 @@ void DebuggerItemManagerPrivate::readLegacyDebuggers(const FileName &file)
|
||||
|
||||
static FileName userSettingsFileName()
|
||||
{
|
||||
QFileInfo settingsLocation(ICore::settings()->fileName());
|
||||
return FileName::fromString(settingsLocation.absolutePath() + QLatin1String(DEBUGGER_FILENAME));
|
||||
return FileName::fromString(ICore::userResourcePath() + DEBUGGER_FILENAME);
|
||||
}
|
||||
|
||||
DebuggerItemManagerPrivate::DebuggerItemManagerPrivate()
|
||||
@@ -918,8 +917,7 @@ void DebuggerItemManagerPrivate::readDebuggers(const FileName &fileName, bool is
|
||||
void DebuggerItemManagerPrivate::restoreDebuggers()
|
||||
{
|
||||
// Read debuggers from SDK
|
||||
QFileInfo systemSettingsFile(ICore::settings(QSettings::SystemScope)->fileName());
|
||||
readDebuggers(FileName::fromString(systemSettingsFile.absolutePath() + DEBUGGER_FILENAME), true);
|
||||
readDebuggers(FileName::fromString(ICore::installerResourcePath() + DEBUGGER_FILENAME), true);
|
||||
|
||||
// Read all debuggers from user file.
|
||||
readDebuggers(userSettingsFileName(), false);
|
||||
@@ -929,10 +927,8 @@ void DebuggerItemManagerPrivate::restoreDebuggers()
|
||||
autoDetectGdbOrLldbDebuggers();
|
||||
|
||||
// Add debuggers from pre-3.x profiles.xml
|
||||
QFileInfo systemLocation(ICore::settings(QSettings::SystemScope)->fileName());
|
||||
readLegacyDebuggers(FileName::fromString(systemLocation.absolutePath() + QLatin1String(DEBUGGER_LEGACY_FILENAME)));
|
||||
QFileInfo userLocation(ICore::settings()->fileName());
|
||||
readLegacyDebuggers(FileName::fromString(userLocation.absolutePath() + QLatin1String(DEBUGGER_LEGACY_FILENAME)));
|
||||
readLegacyDebuggers(FileName::fromString(ICore::installerResourcePath() + DEBUGGER_LEGACY_FILENAME));
|
||||
readLegacyDebuggers(FileName::fromString(ICore::userResourcePath() + DEBUGGER_LEGACY_FILENAME));
|
||||
}
|
||||
|
||||
void DebuggerItemManagerPrivate::saveDebuggers()
|
||||
|
@@ -150,7 +150,7 @@ void DeviceManager::load()
|
||||
// read devices file from global settings path
|
||||
QHash<Core::Id, Core::Id> defaultDevices;
|
||||
QList<IDevice::Ptr> sdkDevices;
|
||||
if (reader.load(systemSettingsFilePath(QLatin1String("/qtcreator/devices.xml"))))
|
||||
if (reader.load(systemSettingsFilePath(QLatin1String("/devices.xml"))))
|
||||
sdkDevices = fromMap(reader.restoreValues().value(DeviceManagerKey).toMap(), &defaultDevices);
|
||||
// read devices file from user settings path
|
||||
QList<IDevice::Ptr> userDevices;
|
||||
@@ -230,9 +230,8 @@ Utils::FileName DeviceManager::settingsFilePath(const QString &extension)
|
||||
|
||||
Utils::FileName DeviceManager::systemSettingsFilePath(const QString &deviceFileRelativePath)
|
||||
{
|
||||
return Utils::FileName::fromString(
|
||||
QFileInfo(Core::ICore::settings(QSettings::SystemScope)->fileName()).absolutePath()
|
||||
+ deviceFileRelativePath);
|
||||
return Utils::FileName::fromString(Core::ICore::installerResourcePath()
|
||||
+ deviceFileRelativePath);
|
||||
}
|
||||
|
||||
void DeviceManager::addDevice(const IDevice::ConstPtr &_device)
|
||||
|
@@ -53,12 +53,11 @@ const char KIT_DATA_KEY[] = "Profile.";
|
||||
const char KIT_COUNT_KEY[] = "Profile.Count";
|
||||
const char KIT_FILE_VERSION_KEY[] = "Version";
|
||||
const char KIT_DEFAULT_KEY[] = "Profile.Default";
|
||||
const char KIT_FILENAME[] = "/qtcreator/profiles.xml";
|
||||
const char KIT_FILENAME[] = "/profiles.xml";
|
||||
|
||||
static FileName settingsFileName()
|
||||
{
|
||||
QFileInfo settingsLocation(ICore::settings()->fileName());
|
||||
return FileName::fromString(settingsLocation.absolutePath() + QLatin1String(KIT_FILENAME));
|
||||
return FileName::fromString(ICore::resourcePath() + KIT_FILENAME);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -131,8 +130,7 @@ void KitManager::restoreKits()
|
||||
QList<Kit *> sdkKits;
|
||||
|
||||
// read all kits from SDK
|
||||
QFileInfo systemSettingsFile(ICore::settings(QSettings::SystemScope)->fileName());
|
||||
QFileInfo kitFile(systemSettingsFile.absolutePath() + QLatin1String(KIT_FILENAME));
|
||||
QFileInfo kitFile(ICore::installerResourcePath() + KIT_FILENAME);
|
||||
if (kitFile.exists()) {
|
||||
KitList system = restoreKits(FileName(kitFile));
|
||||
// make sure we mark these as autodetected and run additional setup logic
|
||||
|
@@ -44,14 +44,13 @@
|
||||
static const char TOOLCHAIN_DATA_KEY[] = "ToolChain.";
|
||||
static const char TOOLCHAIN_COUNT_KEY[] = "ToolChain.Count";
|
||||
static const char TOOLCHAIN_FILE_VERSION_KEY[] = "Version";
|
||||
static const char TOOLCHAIN_FILENAME[] = "/qtcreator/toolchains.xml";
|
||||
static const char TOOLCHAIN_FILENAME[] = "/toolchains.xml";
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
static FileName settingsFileName(const QString &path)
|
||||
{
|
||||
QFileInfo settingsLocation(Core::ICore::settings()->fileName());
|
||||
return FileName::fromString(settingsLocation.absolutePath() + path);
|
||||
return FileName::fromString(Core::ICore::resourcePath() + path);
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -304,9 +303,8 @@ void ToolChainManager::restoreToolChains()
|
||||
|
||||
QList<ToolChain *> ToolChainManager::readSystemFileToolChains()
|
||||
{
|
||||
QFileInfo systemSettingsFile(Core::ICore::settings(QSettings::SystemScope)->fileName());
|
||||
QList<ToolChain *> systemTcs
|
||||
= restoreFromFile(FileName::fromString(systemSettingsFile.absolutePath() + QLatin1String(TOOLCHAIN_FILENAME)));
|
||||
QList<ToolChain *> systemTcs = restoreFromFile(
|
||||
FileName::fromString(Core::ICore::installerResourcePath() + TOOLCHAIN_FILENAME));
|
||||
|
||||
foreach (ToolChain *tc, systemTcs)
|
||||
tc->setDetection(ToolChain::AutoDetection);
|
||||
|
@@ -1571,8 +1571,7 @@ static QString maddeRoot(const QString &qmakePath)
|
||||
void UserFileVersion11Upgrader::parseQtversionFile()
|
||||
{
|
||||
PersistentSettingsReader reader;
|
||||
QFileInfo settingsLocation = QFileInfo(Core::ICore::settings()->fileName());
|
||||
reader.load(FileName::fromString(settingsLocation.absolutePath() + "/qtversion.xml"));
|
||||
reader.load(FileName::fromString(Core::ICore::userResourcePath() + "/../qtversion.xml"));
|
||||
QVariantMap data = reader.restoreValues();
|
||||
|
||||
int count = data.value("QtVersion.Count", 0).toInt();
|
||||
@@ -1610,8 +1609,7 @@ void UserFileVersion11Upgrader::parseQtversionFile()
|
||||
void UserFileVersion11Upgrader::parseToolChainFile()
|
||||
{
|
||||
PersistentSettingsReader reader;
|
||||
QFileInfo settingsLocation(Core::ICore::settings()->fileName());
|
||||
reader.load(FileName::fromString(settingsLocation.absolutePath() + "/toolChains.xml"));
|
||||
reader.load(FileName::fromString(Core::ICore::userResourcePath() + "/../toolChains.xml"));
|
||||
QVariantMap data = reader.restoreValues();
|
||||
int count = data.value("ToolChain.Count", 0).toInt();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
|
@@ -63,7 +63,7 @@ using namespace Internal;
|
||||
const char QTVERSION_DATA_KEY[] = "QtVersion.";
|
||||
const char QTVERSION_TYPE_KEY[] = "QtVersion.Type";
|
||||
const char QTVERSION_FILE_VERSION_KEY[] = "Version";
|
||||
const char QTVERSION_FILENAME[] = "/qtcreator/qtversion.xml";
|
||||
const char QTVERSION_FILENAME[] = "/qtversion.xml";
|
||||
|
||||
static QMap<int, BaseQtVersion *> m_versions;
|
||||
static int m_idcount = 0;
|
||||
@@ -77,16 +77,12 @@ enum { debug = 0 };
|
||||
|
||||
static FileName globalSettingsFileName()
|
||||
{
|
||||
QSettings *globalSettings = ExtensionSystem::PluginManager::globalSettings();
|
||||
return FileName::fromString(QFileInfo(globalSettings->fileName()).absolutePath()
|
||||
+ QLatin1String(QTVERSION_FILENAME));
|
||||
return FileName::fromString(Core::ICore::installerResourcePath() + QTVERSION_FILENAME);
|
||||
}
|
||||
|
||||
static FileName settingsFileName(const QString &path)
|
||||
{
|
||||
QSettings *settings = ExtensionSystem::PluginManager::settings();
|
||||
QFileInfo settingsLocation(settings->fileName());
|
||||
return FileName::fromString(settingsLocation.absolutePath() + path);
|
||||
return FileName::fromString(Core::ICore::resourcePath() + path);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user