diff options
Diffstat (limited to 'src/qmldom')
-rw-r--r-- | src/qmldom/qqmldomelements_p.h | 2 | ||||
-rw-r--r-- | src/qmldom/qqmldommoduleindex.cpp | 2 | ||||
-rw-r--r-- | src/qmldom/qqmldomreformatter.cpp | 27 | ||||
-rw-r--r-- | src/qmldom/qqmldomtop.cpp | 22 |
4 files changed, 37 insertions, 16 deletions
diff --git a/src/qmldom/qqmldomelements_p.h b/src/qmldom/qqmldomelements_p.h index f33face3f3..0c78b986fe 100644 --- a/src/qmldom/qqmldomelements_p.h +++ b/src/qmldom/qqmldomelements_p.h @@ -733,7 +733,6 @@ public: : CommentableDomElement(pathFromOwner), m_name(name), m_values(values) { } - EnumDecl &operator=(const EnumDecl &) = default; bool iterateDirectSubpaths(DomItem &self, DirectVisitor visitor) override; @@ -773,7 +772,6 @@ public: DomType kind() const override { return kindValue; } QmlObject(Path pathFromOwner = Path()); - QmlObject &operator=(const QmlObject &) = default; bool iterateDirectSubpaths(DomItem &self, DirectVisitor) override; bool iterateBaseDirectSubpaths(DomItem &self, DirectVisitor); QList<QString> fields() const; diff --git a/src/qmldom/qqmldommoduleindex.cpp b/src/qmldom/qqmldommoduleindex.cpp index 700537d287..47a2d9192f 100644 --- a/src/qmldom/qqmldommoduleindex.cpp +++ b/src/qmldom/qqmldommoduleindex.cpp @@ -145,7 +145,7 @@ ModuleIndex::~ModuleIndex() auto it = scopes.begin(); auto end = scopes.end(); while (it != end) { - free(*it); + delete *it; ++it; } } diff --git a/src/qmldom/qqmldomreformatter.cpp b/src/qmldom/qqmldomreformatter.cpp index 4232097d17..a5022f95e1 100644 --- a/src/qmldom/qqmldomreformatter.cpp +++ b/src/qmldom/qqmldomreformatter.cpp @@ -585,16 +585,27 @@ protected: return false; } + + void outputScope(VariableScope scope) { + switch (scope) { + case VariableScope::Const: + out("const "); + break; + case VariableScope::Let: + out("let "); + break; + case VariableScope::Var: + out("var "); + break; + default: + break; + } + } + bool visit(PatternElement *ast) override { if (ast->isForDeclaration) { - if (ast->scope == VariableScope::Var) { - out("var "); - } else if (ast->scope == VariableScope::Let) { - out("let "); - } else if (ast->scope == VariableScope::Const) { - out("const "); - } + outputScope(ast->scope); } accept(ast->bindingTarget); switch (ast->type) { @@ -678,7 +689,7 @@ protected: if (ast->initialiser) { accept(ast->initialiser); } else if (ast->declarations) { - out("var "); + outputScope(ast->declarations->declaration->scope); accept(ast->declarations); } out("; "); // ast->firstSemicolonToken diff --git a/src/qmldom/qqmldomtop.cpp b/src/qmldom/qqmldomtop.cpp index ed62310075..e0f88f67c1 100644 --- a/src/qmldom/qqmldomtop.cpp +++ b/src/qmldom/qqmldomtop.cpp @@ -49,7 +49,6 @@ #include <QtQml/private/qqmljsastvisitor_p.h> #include <QtQml/private/qqmljsast_p.h> -#include <QtCore/QAtomicInt> #include <QtCore/QBasicMutex> #include <QtCore/QCborArray> #include <QtCore/QDebug> @@ -158,11 +157,14 @@ DomUniverse::DomUniverse(QString universeName, Options options): std::shared_ptr<DomUniverse> DomUniverse::guaranteeUniverse(std::shared_ptr<DomUniverse> univ) { - static QAtomicInt counter(0); + const auto next = [] { + static std::atomic<int> counter(0); + return counter.fetch_add(1, std::memory_order_relaxed) + 1; + }; if (univ) return univ; return std::shared_ptr<DomUniverse>( - new DomUniverse(QLatin1String("universe") + QString::number(++counter))); + new DomUniverse(QLatin1String("universe") + QString::number(next()))); } DomItem DomUniverse::create(QString universeName, Options options) @@ -287,11 +289,14 @@ void DomUniverse::loadFile(DomItem &self, QString canonicalFilePath, QString log case DomType::QmlFile: case DomType::QmltypesFile: case DomType::QmldirFile: - case DomType::QmlDirectory: + case DomType::QmlDirectory: { + // Protect the queue from concurrent access. + QMutexLocker l(mutex()); m_queue.enqueue(ParsingTask { QDateTime::currentDateTime(), loadOptions, fType, canonicalFilePath, logicalPath, code, codeDate, self.ownerAs<DomUniverse>(), callback }); break; + } default: self.addError(myErrors() .error(tr("Ignoring request to load file %1 of unexpected type %2, " @@ -350,7 +355,14 @@ updateEntry(DomItem &univ, std::shared_ptr<T> newItem, void DomUniverse::execQueue() { - ParsingTask t = m_queue.dequeue(); + ParsingTask t; + { + // Protect the queue from concurrent access. + QMutexLocker l(mutex()); + if (m_queue.isEmpty()) + return; + t = m_queue.dequeue(); + } shared_ptr<DomUniverse> topPtr = t.requestingUniverse.lock(); if (!topPtr) { myErrors().error(tr("Ignoring callback for loading of %1: universe is not valid anymore").arg(t.canonicalPath)).handle(); |