diff options
Diffstat (limited to 'src/qml/jsruntime')
| -rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 2 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4resolvedtypereference_p.h | 36 |
2 files changed, 35 insertions, 3 deletions
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 |
