Commit b899684a authored by Aleix Pol's avatar Aleix Pol Committed by Aleix Pol Gonzalez

Don't put QString in static attributes

It crashed in some places on our code-base due to the so-called "static
initialization order fiasco".
As a solution, it turns the variable into a function. This shouldn't have
a penalty due to QStringLiteral.

Change-Id: I9f8a955afdff878dc2f0db16fec861d81250c243
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 954cabdd
......@@ -734,7 +734,7 @@ void Preprocessor::State::updateIncludeGuardState_helper(IncludeGuardStateHint h
#endif // DEBUG_INCLUDE_GUARD_TRACKING
}
const QString Preprocessor::configurationFileName = QLatin1String("<configuration>");
QString Preprocessor::configurationFileName() { return QStringLiteral("<configuration>"); }
Preprocessor::Preprocessor(Client *client, Environment *env)
: m_client(client)
......@@ -1978,7 +1978,7 @@ void Preprocessor::handleIfDefDirective(bool checkUndefined, PPToken *tk)
// the macro is a feature constraint(e.g. QT_NO_XXX)
if (checkUndefined && macroName.startsWith("QT_NO_")) {
if (macro->fileName() == configurationFileName) {
if (macro->fileName() == configurationFileName()) {
// and it' defined in a pro file (e.g. DEFINES += QT_NO_QOBJECT)
value = false; // take the branch
......
......@@ -77,7 +77,7 @@ class CPLUSPLUS_EXPORT Preprocessor
typedef Internal::Value Value;
public:
static const QString configurationFileName;
static QString configurationFileName();
public:
Preprocessor(Client *client, Environment *env);
......
......@@ -481,7 +481,7 @@ bool operator <(const ImportKey &i1, const ImportKey &i2)
return i1.compare(i2) < 0;
}
const QString Export::LibraryTypeName = QLatin1String("%Library%");
QString Export::libraryTypeName() { return QStringLiteral("%Library%"); }
Export::Export()
: intrinsic(false)
......
......@@ -131,10 +131,10 @@ bool operator <(const ImportKey &i1, const ImportKey &i2);
class QMLJS_EXPORT Export
{
public:
static const QString LibraryTypeName;
static QString libraryTypeName();
Export();
Export(ImportKey exportName, QString pathRequired, bool intrinsic = false,
const QString &typeName = LibraryTypeName);
const QString &typeName = libraryTypeName());
ImportKey exportName;
QString pathRequired;
QString typeName;
......@@ -211,9 +211,9 @@ public:
void removeCoreImport(const QString &importId);
void addExport(const QString &importId, const ImportKey &importKey,
const QString &requiredPath, const QString &typeName = Export::LibraryTypeName);
const QString &requiredPath, const QString &typeName = Export::libraryTypeName());
void removeExport(const QString &importId, const ImportKey &importKey,
const QString &requiredPath, const QString &typeName = Export::LibraryTypeName);
const QString &requiredPath, const QString &typeName = Export::libraryTypeName());
void iterateOnCoreImports(const ViewerContext &vContext,
std::function<bool(const CoreImport &)> const &iterF) const;
......
This diff is collapsed.
......@@ -355,28 +355,28 @@ private:
static bool maybeSchemaName(const QString &s);
static const QString kType;
static const QString kProperties;
static const QString kPatternProperties;
static const QString kAdditionalProperties;
static const QString kItems;
static const QString kAdditionalItems;
static const QString kRequired;
static const QString kDependencies;
static const QString kMinimum;
static const QString kMaximum;
static const QString kExclusiveMinimum;
static const QString kExclusiveMaximum;
static const QString kMinItems;
static const QString kMaxItems;
static const QString kUniqueItems;
static const QString kPattern;
static const QString kMinLength;
static const QString kMaxLength;
static const QString kTitle;
static const QString kDescription;
static const QString kExtends;
static const QString kRef;
static QString kType();
static QString kProperties();
static QString kPatternProperties();
static QString kAdditionalProperties();
static QString kItems();
static QString kAdditionalItems();
static QString kRequired();
static QString kDependencies();
static QString kMinimum();
static QString kMaximum();
static QString kExclusiveMinimum();
static QString kExclusiveMaximum();
static QString kMinItems();
static QString kMaxItems();
static QString kUniqueItems();
static QString kPattern();
static QString kMinLength();
static QString kMaxLength();
static QString kTitle();
static QString kDescription();
static QString kExtends();
static QString kRef();
struct Context
{
......
......@@ -253,7 +253,7 @@ QString CppModelManager::editorConfigurationFileName()
QString CppModelManager::configurationFileName()
{
return Preprocessor::configurationFileName;
return Preprocessor::configurationFileName();
}
void CppModelManager::updateModifiedSourceFiles()
......
......@@ -154,7 +154,7 @@ static QString qualifiedTypeNameForContext(const ObjectValue *objectValue,
case ImportType::Library:
{
QString typeName = objectValue->className();
if (!e.typeName.isEmpty() && e.typeName != Export::LibraryTypeName) {
if (!e.typeName.isEmpty() && e.typeName != Export::libraryTypeName()) {
typeName = e.typeName;
if (typeName != objectValue->className())
qCWarning(qmljsLog) << "Outdated classname " << objectValue->className()
......
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