diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-01-29 16:41:59 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-01-29 16:52:58 +0100 |
commit | b684ba219493fb7b0108ae367d6d033aaa28053b (patch) | |
tree | f1fec8922da198e231416b50ef8f441ef6db065b /src/qml/qml/qqmlengine.cpp | |
parent | 97a5cf86345fd72cdff83c03664c19a8f5cdf79a (diff) | |
parent | 8354851b628ebae567a9125cbd0ba69268470c1b (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Conflicts:
dependencies.yaml
Change-Id: Ie3e9dc62031a85e5e81cbdf04694b95159d49fca
Diffstat (limited to 'src/qml/qml/qqmlengine.cpp')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index f11959b7fb..5d7dddd153 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -101,8 +101,6 @@ # endif #endif // Q_OS_WIN -Q_DECLARE_METATYPE(QQmlProperty) - QT_BEGIN_NAMESPACE // Declared in qqml.h @@ -1309,6 +1307,21 @@ void QQmlEngine::setOutputWarningsToStandardError(bool enabled) } /*! + \qmlproperty string Qt::uiLanguage + \since 5.15 + + The uiLanguage holds the name of the language to be used for user interface + string translations. It is exposed in C++ as QQmlEngine::uiLanguage property. + + You can set the value freely and use it in bindings. It is recommended to set it + after installing translators in your application. By convention, an empty string + means no translation from the language used in the source code is intended to occur. + + If you're using QQmlApplicationEngine and the value changes, QQmlEngine::retranslate() + will be called. +*/ + +/*! \fn template<typename T> T QQmlEngine::singletonInstance(int qmlTypeId) Returns the instance of a singleton type that was registered under \a qmlTypeId. @@ -2341,12 +2354,23 @@ int QQmlEnginePrivate::listType(int t) const return QQmlMetaType::listType(t); } + +static QQmlPropertyCache *propertyCacheForPotentialInlineComponentType(int t, const QHash<int, QV4::ExecutableCompilationUnit *>::const_iterator &iter) { + if (t != (*iter)->metaTypeId) { + // this is an inline component, and what we have in the iterator is currently the parent compilation unit + for (auto &&icDatum: (*iter)->inlineComponentData) + if (icDatum.typeIds.id == t) + return (*iter)->propertyCaches.at(icDatum.objectIndex); + } + return (*iter)->rootPropertyCache().data(); +} + QQmlMetaObject QQmlEnginePrivate::rawMetaObjectForType(int t) const { Locker locker(this); auto iter = m_compositeTypes.constFind(t); if (iter != m_compositeTypes.cend()) { - return QQmlMetaObject((*iter)->rootPropertyCache().data()); + return propertyCacheForPotentialInlineComponentType(t, iter); } else { QQmlType type = QQmlMetaType::qmlType(t); return QQmlMetaObject(type.baseMetaObject()); @@ -2358,7 +2382,7 @@ QQmlMetaObject QQmlEnginePrivate::metaObjectForType(int t) const Locker locker(this); auto iter = m_compositeTypes.constFind(t); if (iter != m_compositeTypes.cend()) { - return QQmlMetaObject((*iter)->rootPropertyCache().data()); + return propertyCacheForPotentialInlineComponentType(t, iter); } else { QQmlType type = QQmlMetaType::qmlType(t); return QQmlMetaObject(type.metaObject()); @@ -2370,7 +2394,7 @@ QQmlPropertyCache *QQmlEnginePrivate::propertyCacheForType(int t) Locker locker(this); auto iter = m_compositeTypes.constFind(t); if (iter != m_compositeTypes.cend()) { - return (*iter)->rootPropertyCache().data(); + return propertyCacheForPotentialInlineComponentType(t, iter); } else { QQmlType type = QQmlMetaType::qmlType(t); locker.unlock(); @@ -2383,7 +2407,7 @@ QQmlPropertyCache *QQmlEnginePrivate::rawPropertyCacheForType(int t, int minorVe Locker locker(this); auto iter = m_compositeTypes.constFind(t); if (iter != m_compositeTypes.cend()) { - return (*iter)->rootPropertyCache().data(); + return propertyCacheForPotentialInlineComponentType(t, iter); } else { QQmlType type = QQmlMetaType::qmlType(t); locker.unlock(); @@ -2403,6 +2427,9 @@ void QQmlEnginePrivate::registerInternalCompositeType(QV4::ExecutableCompilation // The QQmlCompiledData is not referenced here, but it is removed from this // hash in the QQmlCompiledData destructor m_compositeTypes.insert(compilationUnit->metaTypeId, compilationUnit); + for (auto &&data: compilationUnit->inlineComponentData) { + m_compositeTypes.insert(data.typeIds.id, compilationUnit); + } } void QQmlEnginePrivate::unregisterInternalCompositeType(QV4::ExecutableCompilationUnit *compilationUnit) @@ -2411,6 +2438,14 @@ void QQmlEnginePrivate::unregisterInternalCompositeType(QV4::ExecutableCompilati Locker locker(this); m_compositeTypes.remove(compilationUnit->metaTypeId); + for (auto&& icDatum: compilationUnit->inlineComponentData) + m_compositeTypes.remove(icDatum.typeIds.id); +} + +QV4::ExecutableCompilationUnit *QQmlEnginePrivate::obtainExecutableCompilationUnit(int typeId) +{ + Locker locker(this); + return m_compositeTypes.value(typeId, nullptr); } template<> |