Commit 544783cf authored by Ulf Hermann's avatar Ulf Hermann
Browse files

ProjectExplorer: Avoid static initialization fiasko



The search paths can only be constructed once the extension system is
ready. This may never happen if the plugin is loaded directly, e.g.
from an autotest.

Change-Id: Ibfcb7bbb6138480d772d5097aaa8b0ae44d1b043
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 10c8d5f0
......@@ -84,11 +84,6 @@ static const char PAGE_INDEX_KEY[] = "index";
static const char OPTIONS_KEY[] = "options";
static const char PLATFORM_INDEPENDENT_KEY[] = "platformIndependent";
QList<Utils::FileName> JsonWizardFactory::m_searchPaths
= QList<Utils::FileName>()
<< Utils::FileName::fromString(Core::ICore::userResourcePath() + QLatin1Char('/') + QLatin1String(WIZARD_PATH))
<< Utils::FileName::fromString(Core::ICore::resourcePath() + QLatin1Char('/') + QLatin1String(WIZARD_PATH));
int JsonWizardFactory::m_verbose = 0;
// Return locale language attribute "de_UTF8" -> "de", empty string for "C"
......@@ -210,7 +205,7 @@ QList<JsonWizardFactory *> JsonWizardFactory::createWizardFactories()
const QString wizardFileName = QLatin1String(WIZARD_FILE);
QList <JsonWizardFactory *> result;
foreach (const Utils::FileName &path, m_searchPaths) {
foreach (const Utils::FileName &path, searchPaths()) {
if (path.isEmpty())
continue;
......@@ -321,9 +316,19 @@ JsonWizardFactory *JsonWizardFactory::createWizardFactory(const QVariantMap &dat
return factory;
}
QList<Utils::FileName> &JsonWizardFactory::searchPaths()
{
static QList<Utils::FileName> m_searchPaths = QList<Utils::FileName>()
<< Utils::FileName::fromString(Core::ICore::userResourcePath() + QLatin1Char('/') +
QLatin1String(WIZARD_PATH))
<< Utils::FileName::fromString(Core::ICore::resourcePath() + QLatin1Char('/') +
QLatin1String(WIZARD_PATH));
return m_searchPaths;
}
void JsonWizardFactory::addWizardPath(const Utils::FileName &path)
{
m_searchPaths.append(path);
searchPaths().append(path);
}
void JsonWizardFactory::setVerbose(int level)
......
......@@ -95,6 +95,7 @@ private:
static QList<JsonWizardFactory *> createWizardFactories();
static JsonWizardFactory *createWizardFactory(const QVariantMap &data, const QDir &baseDir,
QString *errorMessage);
static QList<Utils::FileName> &searchPaths();
static void setVerbose(int level);
static int verbose();
......@@ -110,7 +111,6 @@ private:
Core::FeatureSet m_preferredFeatures;
static QList<Utils::FileName> m_searchPaths;
static int m_verbose;
friend class ProjectExplorerPlugin;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment