From 5b0a98fa16330f220d3fbf67e9a55c8632d30129 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 5 Feb 2018 14:18:18 +0100 Subject: Clean up manual refcounting of compilation units Replace manual use in QQmlData and QQmlData::DeferredData with QQmlRefPointer. Due to forward declaration trouble this required declaring a non-inline constructor/destructor for QQmlData and DeferedData and disabling copying, so that not every C++ compilation unit including qqmldata_p.h needs to instantiate the QQmlRefPointer destructor and thus know whether QV4::CompiledData::CompilationUnit has release(), etc. The out-of-line declarations however should not have any negative impact as the only call sites are within qqmlengine.cpp, too. Change-Id: I2e8295cb0d7f876a5d7d18765dbac285184e6c99 Reviewed-by: Lars Knoll --- src/qml/qml/qqmldata_p.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/qml/qml/qqmldata_p.h') diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 5794e6f0c5..17d145f939 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -116,6 +117,7 @@ class Q_QML_PRIVATE_EXPORT QQmlData : public QAbstractDeclarativeData { public: QQmlData(); + ~QQmlData(); static inline void init() { static bool initialized = false; @@ -219,12 +221,15 @@ public: quint32 jsEngineId; // id of the engine that created the jsWrapper struct DeferredData { + DeferredData(); + ~DeferredData(); unsigned int deferredIdx; QMultiHash bindings; - QV4::CompiledData::CompilationUnit *compilationUnit;//Not always the same as the other compilation unit + QQmlRefPointer compilationUnit;//Not always the same as the other compilation unit QQmlContextData *context;//Could be either context or outerContext + Q_DISABLE_COPY(DeferredData); }; - QV4::CompiledData::CompilationUnit *compilationUnit; + QQmlRefPointer compilationUnit; QVector deferredData; void deferData(int objectIndex, QV4::CompiledData::CompilationUnit *, QQmlContextData *); @@ -299,6 +304,7 @@ private: const BindingBitsType *bits = (bindingBitsArraySize == InlineBindingArraySize) ? bindingBitsValue : bindingBits; return bits[offset] & bitFlagForBit(bit); } + Q_DISABLE_COPY(QQmlData); }; bool QQmlData::wasDeleted(const QObject *object) -- cgit v1.2.3