From 9c4621217f47b8427e284423d4e5c5e4dba00bfc Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 23 Dec 2015 18:26:50 +0100 Subject: Revert "Fix QtSharedPointer::ExternalRefCountData object leaks" This reverts commit 839d2d3e2368bc8e107d22203b0611c852f54319, which has been causing crashes in qtquickcontrols2 auto tests and making it nearly impossible to integrate anything over the past few days. Change-Id: I570b286a067aae5e3c2d8c56ad601e1a6cb58c20 Task-number: QTBUG-50134 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4persistent.cpp | 7 ------- src/qml/jsruntime/qv4qobjectwrapper.cpp | 5 ----- src/qml/jsruntime/qv4qobjectwrapper_p.h | 1 - src/qml/memory/qv4mm.cpp | 11 ++--------- src/qml/memory/qv4mm_p.h | 2 -- src/qml/types/qqmllistmodel.cpp | 3 --- 6 files changed, 2 insertions(+), 27 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp index 032ad0d00a..4a0f84b685 100644 --- a/src/qml/jsruntime/qv4persistent.cpp +++ b/src/qml/jsruntime/qv4persistent.cpp @@ -34,7 +34,6 @@ #include "qv4persistent_p.h" #include #include "qv4object_p.h" -#include "qv4qobjectwrapper_p.h" #include "PageAllocation.h" using namespace QV4; @@ -205,12 +204,6 @@ void PersistentValueStorage::free(Value *v) Page *p = getPage(v); - // Keep track of QObjectWrapper to release its resources later in MemoryManager::sweep() - if (p->header.engine) { - if (QObjectWrapper *qobjectWrapper = v->as()) - p->header.engine->memoryManager->m_pendingDestroyedObjectWrappers.push_back(qobjectWrapper->d()); - } - v->setTag(QV4::Value::Empty_Type); v->setInt_32(p->header.freeList); p->header.freeList = v - p->values; diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 2cb8991055..8f471132b7 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1019,11 +1019,6 @@ void QObjectWrapper::markObjects(Heap::Base *that, QV4::ExecutionEngine *e) void QObjectWrapper::destroyObject(bool lastCall) { Heap::QObjectWrapper *h = d(); - destroyObject(h, lastCall); -} - -void QObjectWrapper::destroyObject(Heap::QObjectWrapper *h, bool lastCall) -{ if (!h->internalClass) return; // destroyObject already got called diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index 29e1263f2d..1126013806 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -120,7 +120,6 @@ struct Q_QML_EXPORT QObjectWrapper : public Object void setProperty(ExecutionEngine *engine, int propertyIndex, const Value &value); void destroyObject(bool lastCall); - static void destroyObject(Heap::QObjectWrapper *h, bool lastCall); protected: static bool isEqualTo(Managed *that, Managed *o); diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 053dfb856c..5181bf912b 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -41,6 +41,8 @@ #include "StdLibExtras.h" #include +#include +#include #include #include @@ -435,15 +437,6 @@ void MemoryManager::sweep(bool lastSweep) (*it) = Primitive::undefinedValue(); } - // Some QV4::QObjectWrapper objects will be removed from PersistentValueStorage in WeakValue::~WeakValue() - // before MemoryManager::sweep() is being called, in this case we will never have a chance to call detroyObject() - // on those QV4::QObjectWrapper objects. Here we call detroyObject() for each pending destroyed Heap::QObjectWrapper - // object on the heap to make sure that we can release all the resources held by them - for (QVector::const_iterator it = m_pendingDestroyedObjectWrappers.constBegin(); - it != m_pendingDestroyedObjectWrappers.constEnd(); ++it) - QObjectWrapper::destroyObject(*it, lastSweep); - m_pendingDestroyedObjectWrappers.clear(); - if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) { for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) { if (!it.value().isNullOrUndefined()) diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h index 69aae1c5bf..3543da0907 100644 --- a/src/qml/memory/qv4mm_p.h +++ b/src/qml/memory/qv4mm_p.h @@ -49,7 +49,6 @@ #include #include #include -#include //#define DETAILED_MM_STATS @@ -328,7 +327,6 @@ public: QScopedPointer m_d; PersistentValueStorage *m_persistentValues; PersistentValueStorage *m_weakValues; - QVector m_pendingDestroyedObjectWrappers; }; } diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 4b0aa47c63..a4c0f7043f 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -2277,9 +2277,6 @@ QQmlV4Handle QQmlListModel::get(int index) const } else { QObject *object = m_listModel->getOrCreateModelObject(const_cast(this), index); result = scope.engine->memoryManager->allocObject(object, const_cast(this), index); - // Keep track of the QObjectWrapper in persistent value storage - QV4::Value *val = scope.engine->memoryManager->m_weakValues->allocate(); - *val = result; } } -- cgit v1.2.3