diff options
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/Qt5QmlConfigExtras.cmake.in | 10 | ||||
-rw-r--r-- | src/qml/doc/src/external-resources.qdoc | 4 | ||||
-rw-r--r-- | src/qml/doc/src/javascript/hostenvironment.qdoc | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4resolvedtypereference_p.h | 36 | ||||
-rw-r--r-- | src/qml/qml/qqmlapplicationengine.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlapplicationengine_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmltypedata.cpp | 9 |
8 files changed, 57 insertions, 10 deletions
diff --git a/src/qml/Qt5QmlConfigExtras.cmake.in b/src/qml/Qt5QmlConfigExtras.cmake.in index 9ddb9885cd..4242143bca 100644 --- a/src/qml/Qt5QmlConfigExtras.cmake.in +++ b/src/qml/Qt5QmlConfigExtras.cmake.in @@ -1,5 +1,7 @@ -file(GLOB _qt5qml_other_plugins "${CMAKE_CURRENT_LIST_DIR}/Qt5Qml_*Factory.cmake") +if(QT5_STRICT_PLUGIN_GLOB OR Qt5Qml_STRICT_PLUGIN_GLOB) + file(GLOB _qt5qml_other_plugins "${CMAKE_CURRENT_LIST_DIR}/Qt5Qml_*Factory.cmake") -foreach(_other_plugin ${_qt5qml_other_plugins}) - include(${_other_plugin} OPTIONAL) -endforeach() + foreach(_other_plugin ${_qt5qml_other_plugins}) + include(${_other_plugin} OPTIONAL) + endforeach() +endif() diff --git a/src/qml/doc/src/external-resources.qdoc b/src/qml/doc/src/external-resources.qdoc index 17ac7693bc..c11174db43 100644 --- a/src/qml/doc/src/external-resources.qdoc +++ b/src/qml/doc/src/external-resources.qdoc @@ -76,3 +76,7 @@ \externalpage https://fontawesome.com/ \title Font Awesome */ +/*! + \externalpage https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator + \title Nullish Coalescing +*/ diff --git a/src/qml/doc/src/javascript/hostenvironment.qdoc b/src/qml/doc/src/javascript/hostenvironment.qdoc index c22c392b80..bc75f843fb 100644 --- a/src/qml/doc/src/javascript/hostenvironment.qdoc +++ b/src/qml/doc/src/javascript/hostenvironment.qdoc @@ -42,6 +42,8 @@ Like a browser or server-side JavaScript environment, the QML runtime implements all of the built-in types and functions defined by the standard, such as Object, Array, and Math. The QML runtime implements the 7th edition of the standard. +Since Qt 5.15 \l{Nullish Coalescing} is also implemented in the QML runtime. + The standard ECMAScript built-ins are not explicitly documented in the QML documentation. For more information on their use, please refer to the ECMA-262 7th edition standard or one of the many online JavaScript reference and tutorial sites, such as the \l{W3Schools JavaScript Reference} (JavaScript Objects diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 55884aa42c..51e63f3608 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1562,7 +1562,7 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int retn = QVariant(typeHint, temp); QMetaType::destroy(typeHint, temp); auto retnAsIterable = retn.value<QtMetaTypePrivate::QSequentialIterableImpl>(); - if (retnAsIterable._iteratorCapabilities & QtMetaTypePrivate::ContainerIsAppendable) { + if (retnAsIterable.containerCapabilities() & QtMetaTypePrivate::ContainerIsAppendable) { auto const length = a->getLength(); QV4::ScopedValue arrayValue(scope); for (qint64 i = 0; i < length; ++i) { diff --git a/src/qml/jsruntime/qv4resolvedtypereference_p.h b/src/qml/jsruntime/qv4resolvedtypereference_p.h index 88b77cf2a8..7e8bedad62 100644 --- a/src/qml/jsruntime/qv4resolvedtypereference_p.h +++ b/src/qml/jsruntime/qv4resolvedtypereference_p.h @@ -67,6 +67,11 @@ class ResolvedTypeReference Q_DISABLE_COPY_MOVE(ResolvedTypeReference) public: ResolvedTypeReference() = default; + ~ResolvedTypeReference() + { + if (m_stronglyReferencesCompilationUnit && m_compilationUnit) + m_compilationUnit->release(); + } QQmlRefPointer<QQmlPropertyCache> propertyCache() const; QQmlRefPointer<QQmlPropertyCache> createPropertyCache(QQmlEngine *); @@ -80,7 +85,33 @@ public: QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit() { return m_compilationUnit; } void setCompilationUnit(QQmlRefPointer<QV4::ExecutableCompilationUnit> unit) { - m_compilationUnit = std::move(unit); + if (m_compilationUnit == unit.data()) + return; + if (m_stronglyReferencesCompilationUnit) { + if (m_compilationUnit) + m_compilationUnit->release(); + m_compilationUnit = unit.take(); + } else { + m_compilationUnit = unit.data(); + } + } + + bool referencesCompilationUnit() const { return m_stronglyReferencesCompilationUnit; } + void setReferencesCompilationUnit(bool doReference) + { + if (doReference == m_stronglyReferencesCompilationUnit) + return; + m_stronglyReferencesCompilationUnit = doReference; + if (!m_compilationUnit) + return; + if (doReference) { + m_compilationUnit->addref(); + } else if (m_compilationUnit->count() == 1) { + m_compilationUnit->release(); + m_compilationUnit = nullptr; + } else { + m_compilationUnit->release(); + } } QQmlRefPointer<QQmlPropertyCache> typePropertyCache() const { return m_typePropertyCache; } @@ -98,12 +129,13 @@ public: private: QQmlType m_type; QQmlRefPointer<QQmlPropertyCache> m_typePropertyCache; - QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit; + QV4::ExecutableCompilationUnit *m_compilationUnit = nullptr; QTypeRevision m_version = QTypeRevision::zero(); // Types such as QQmlPropertyMap can add properties dynamically at run-time and // therefore cannot have a property cache installed when instantiated. bool m_isFullyDynamicType = false; + bool m_stronglyReferencesCompilationUnit = true; }; } // namespace QV4 diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index 6fe8dc5227..a2976b59c3 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -107,8 +107,6 @@ void QQmlApplicationEnginePrivate::_q_loadTranslations() activeTranslator.reset(); } q->retranslate(); -#else - Q_UNUSED(rootFile) #endif } diff --git a/src/qml/qml/qqmlapplicationengine_p.h b/src/qml/qml/qqmlapplicationengine_p.h index 70232b3d52..4568f7cfbb 100644 --- a/src/qml/qml/qqmlapplicationengine_p.h +++ b/src/qml/qml/qqmlapplicationengine_p.h @@ -76,8 +76,10 @@ public: QVariantMap initialProperties; QStringList extraFileSelectors; QString translationsDirectory; +#if QT_CONFIG(translation) QScopedPointer<QTranslator> activeTranslator; bool isInitialized = false; +#endif }; QT_END_NAMESPACE diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp index b264528daa..fea0062242 100644 --- a/src/qml/qml/qqmltypedata.cpp +++ b/src/qml/qml/qqmltypedata.cpp @@ -300,7 +300,14 @@ void QQmlTypeData::setCompileUnit(const Container &container) auto const root = container->objectAt(i); for (auto it = root->inlineComponentsBegin(); it != root->inlineComponentsEnd(); ++it) { auto *typeRef = m_compiledData->resolvedType(it->nameIndex); - typeRef->setCompilationUnit(m_compiledData); // share compilation unit + + // We don't want the type reference to keep a strong reference to the compilation unit + // here. The compilation unit owns the type reference, and having a strong reference + // would prevent the compilation unit from ever getting deleted. We can still be sure + // that the compilation unit outlives the type reference, due to ownership. + typeRef->setReferencesCompilationUnit(false); + + typeRef->setCompilationUnit(m_compiledData); // share compilation unit } } } |