commit faab62da283ca0d9097b58961f7f34c19664f5a0
Author: Ulf Hermann <ulf.hermann@qt.io>
Date:   Mon May 5 11:55:16 2025 +0200

    QtQml: Eliminate QFiniteStack and QQmlParserStatus backlinks
    
    Use a std::vector instead. Track QQmlParserStatus via a QQmlGuard on its
    QObject. This eliminates the need to keep stable references in the
    container that holds QQmlParserStatus. Therefore we don't need to
    allocate all of it in one go anymore, and consequently we can use
    std::vector rather than our homegrown solution.
    
    Since we now record the attached parser status callbacks in the same
    list as the regular ones, we also need to fix their profiler
    integration. Otherwise we would get mismatched profiler events.
    
    Task-number: QTBUG-135286
    Fixes: QTBUG-132827
    Fixes: QTBUG-136951
    Change-Id: I695c8939892b18982f09357a53fe743479218808
    Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
    (cherry picked from commit 72b4dff6c0ba7f51a9e97db73b06135b8d8cb287)

diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt
index 2763f2187f..14eb4e14de 100644
--- a/src/qml/CMakeLists.txt
+++ b/src/qml/CMakeLists.txt
@@ -238,7 +238,6 @@ qt_internal_add_qml_module(Qml
         qml/ftw/qbipointer_p.h
         qml/ftw/qdoubleendedlist_p.h
         qml/ftw/qfieldlist_p.h
-        qml/ftw/qfinitestack_p.h
         qml/ftw/qhashedstring.cpp qml/ftw/qhashedstring_p.h
         qml/ftw/qintrusivelist.cpp qml/ftw/qintrusivelist_p.h
         qml/ftw/qlazilyallocated_p.h
diff --git a/src/qml/debugger/qqmlprofiler_p.h b/src/qml/debugger/qqmlprofiler_p.h
index 2cf0e85760..3c37b558f5 100644
--- a/src/qml/debugger/qqmlprofiler_p.h
+++ b/src/qml/debugger/qqmlprofiler_p.h
@@ -15,7 +15,6 @@
 // We mean it.
 //
 
-#include <private/qfinitestack_p.h>
 #include <private/qqmlbinding_p.h>
 #include <private/qqmlboundsignal_p.h>
 #include <private/qqmlglobal_p.h>
@@ -418,30 +417,30 @@ public:
 
     QQmlVmeProfiler() : profiler(nullptr) {}
 
-    void init(QQmlProfiler *p, int maxDepth)
+    void init(QQmlProfiler *p)
     {
         profiler = p;
-        ranges.allocate(maxDepth);
     }
 
     const QV4::CompiledData::Object *pop()
     {
-        if (ranges.count() > 0)
-            return ranges.pop();
-        else
-            return nullptr;
+        if (ranges.size() > 0) {
+            const auto *result = ranges.back();
+            ranges.pop_back();
+            return result;
+        }
+        return nullptr;
     }
 
     void push(const QV4::CompiledData::Object *object)
     {
-        if (ranges.capacity() > ranges.count())
-            ranges.push(object);
+        ranges.push_back(object);
     }
 
     QQmlProfiler *profiler;
 
 private:
-    QFiniteStack<const QV4::CompiledData::Object *> ranges;
+    std::vector<const QV4::CompiledData::Object *> ranges;
 };
 
 class QQmlObjectCreationProfiler {
diff --git a/src/qml/qml/ftw/qfinitestack_p.h b/src/qml/qml/ftw/qfinitestack_p.h
deleted file mode 100644
index 3e206e205f..0000000000
--- a/src/qml/qml/ftw/qfinitestack_p.h
+++ /dev/null
@@ -1,152 +0,0 @@
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-
-#ifndef QFINITESTACK_P_H
-#define QFINITESTACK_P_H
-
-//
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the Qt API.  It exists purely as an
-// implementation detail.  This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/private/qglobal_p.h>
-
-QT_BEGIN_NAMESPACE
-
-template<typename T>
-struct QFiniteStack {
-    inline QFiniteStack();
-    inline ~QFiniteStack();
-
-    inline void deallocate();
-    inline void allocate(int size);
-
-    inline int capacity() const { return _alloc; }
-
-    inline bool isEmpty() const;
-    inline const T &top() const;
-    inline T &top();
-    inline void push(const T &o);
-    inline T pop();
-    inline int count() const;
-    inline const T &at(int index) const;
-    inline T &operator[](int index);
-private:
-    T *_array;
-    int _alloc;
-    int _size;
-};
-
-template<typename T>
-QFiniteStack<T>::QFiniteStack()
-: _array(nullptr), _alloc(0), _size(0)
-{
-}
-
-template<typename T>
-QFiniteStack<T>::~QFiniteStack()
-{
-    deallocate();
-}
-
-template<typename T>
-bool QFiniteStack<T>::isEmpty() const
-{
-    return _size == 0;
-}
-
-template<typename T>
-const T &QFiniteStack<T>::top() const
-{
-    return _array[_size - 1];
-}
-
-template<typename T>
-T &QFiniteStack<T>::top()
-{
-    return _array[_size - 1];
-}
-
-template<typename T>
-void QFiniteStack<T>::push(const T &o)
-{
-    Q_ASSERT(_size < _alloc);
-    if (QTypeInfo<T>::isComplex) {
-        new (_array + _size++) T(o);
-    } else {
-        _array[_size++] = o;
-    }
-}
-
-template<typename T>
-T QFiniteStack<T>::pop()
-{
-    Q_ASSERT(_size > 0);
-    --_size;
-
-    if (QTypeInfo<T>::isComplex) {
-        T rv = _array[_size];
-        (_array + _size)->~T();
-        return rv;
-    } else {
-        return _array[_size];
-    }
-}
-
-template<typename T>
-int QFiniteStack<T>::count() const
-{
-    return _size;
-}
-
-template<typename T>
-const T &QFiniteStack<T>::at(int index) const
-{
-    return _array[index];
-}
-
-template<typename T>
-T &QFiniteStack<T>::operator[](int index)
-{
-    return _array[index];
-}
-
-template<typename T>
-void QFiniteStack<T>::allocate(int size)
-{
-    Q_ASSERT(_array == nullptr);
-    Q_ASSERT(_alloc == 0);
-    Q_ASSERT(_size == 0);
-
-    if (!size) return;
-
-    _array = (T *)malloc(size * sizeof(T));
-    _alloc = size;
-}
-
-template<typename T>
-void QFiniteStack<T>::deallocate()
-{
-    if (QTypeInfo<T>::isComplex) {
-        T *i = _array + _size;
-        while (i != _array)
-            (--i)->~T();
-    }
-
-    free(_array);
-
-    _array = nullptr;
-    _alloc = 0;
-    _size = 0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QFINITESTACK_P_H
-
diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h
index 3828c931b9..cb5a1a021f 100644
--- a/src/qml/qml/qqmlcomponent_p.h
+++ b/src/qml/qml/qqmlcomponent_p.h
@@ -144,7 +144,7 @@ public:
 
             if (m_creatorOrRequiredProperties.isT1()) {
                 const auto &objects = m_creatorOrRequiredProperties.asT1()->allCreatedObjects();
-                return objects.isEmpty() ? nullptr : objects.at(0);
+                return objects.empty() ? nullptr : objects.at(0);
             }
 
             Q_ASSERT(m_creatorOrRequiredProperties.isT2());
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index bf58775715..1902ac7eab 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -69,9 +69,6 @@ QQmlObjectCreator::QQmlObjectCreator(
     init(parentContext);
 
     sharedState->componentAttached = nullptr;
-    sharedState->allCreatedBindings.allocate(compilationUnit->totalBindingsCount(inlineComponentName));
-    sharedState->allParserStatusCallbacks.allocate(compilationUnit->totalParserStatusCount(inlineComponentName));
-    sharedState->allCreatedObjects.allocate(compilationUnit->totalObjectCount(inlineComponentName));
     sharedState->allJavaScriptObjects = ObjectInCreationGCAnchorList();
     sharedState->creationContext = creationContext;
     sharedState->rootContext.reset();
@@ -79,7 +76,7 @@ QQmlObjectCreator::QQmlObjectCreator(
 
     if (auto profiler = QQmlEnginePrivate::get(engine)->profiler) {
         Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, profiler,
-                sharedState->profiler.init(profiler, compilationUnit->totalParserStatusCount(inlineComponentName)));
+                sharedState->profiler.init(profiler));
     } else {
         Q_UNUSED(profiler);
     }
@@ -127,13 +124,10 @@ QQmlObjectCreator::~QQmlObjectCreator()
 {
     if (topLevelCreator) {
         {
+            // This signals to other methods further up the stack that we have
+            // "recursed" and they should be aborted.
             QQmlObjectCreatorRecursionWatcher watcher(this);
         }
-        for (int i = 0; i < sharedState->allParserStatusCallbacks.count(); ++i) {
-            QQmlParserStatus *ps = sharedState->allParserStatusCallbacks.at(i);
-            if (ps)
-                ps->d = nullptr;
-        }
         while (sharedState->componentAttached) {
             QQmlComponentAttached *a = sharedState->componentAttached;
             a->removeFromList();
@@ -194,7 +188,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI
 
     Q_ASSERT(sharedState->allJavaScriptObjects.canTrack() || topLevelCreator);
     if (topLevelCreator)
-        sharedState->allJavaScriptObjects = ObjectInCreationGCAnchorList(scope, compilationUnit->totalObjectCount(m_inlineComponentName));
+        sharedState->allJavaScriptObjects = ObjectInCreationGCAnchorList(scope);
 
     if (!isComponentRoot && sharedState->creationContext) {
         // otherwise QQmlEnginePrivate::createInternalContext() handles it
@@ -243,7 +237,7 @@ void QQmlObjectCreator::beginPopulateDeferred(const QQmlRefPointer<QQmlContextDa
 
     // FIXME (QTBUG-122956): allocating from the short lived scope does not make any sense
     QV4::Scope valueScope(v4);
-    sharedState->allJavaScriptObjects = ObjectInCreationGCAnchorList(valueScope, compilationUnit->totalObjectCount(m_inlineComponentName));
+    sharedState->allJavaScriptObjects = ObjectInCreationGCAnchorList(valueScope);
 }
 
 void QQmlObjectCreator::populateDeferred(QObject *instance, int deferredIndex,
@@ -837,7 +831,10 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProper
 {
     const QV4::CompiledData::Binding::Type bindingType = binding->type();
     if (bindingType == QV4::CompiledData::Binding::Type_AttachedProperty) {
-        Q_ASSERT(stringAt(compilationUnit->objectAt(binding->value.objectIndex)->inheritedTypeNameIndex).isEmpty());
+        const QV4::CompiledData::Object *obj = compilationUnit->objectAt(binding->value.objectIndex);
+        QQmlObjectCreationProfiler profiler(sharedState->profiler.profiler, obj);
+
+        Q_ASSERT(stringAt(obj->inheritedTypeNameIndex).isEmpty());
         QV4::ResolvedTypeReference *tr = resolvedType(binding->propertyNameIndex);
         Q_ASSERT(tr);
         QQmlType attachedType = tr->type();
@@ -850,6 +847,12 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProper
             else
                 return false;
         }
+
+        Q_QML_OC_PROFILE(
+                sharedState->profiler,
+                profiler.update(compilationUnit.data(), obj, attachedType.qmlTypeName(),
+                                context->url()));
+
         QObject *qmlObject = qmlAttachedPropertiesObject(
                 _qobject, attachedType.attachedPropertiesFunction(enginePrivate));
         if (!qmlObject) {
@@ -859,6 +862,8 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProper
             return false;
         }
 
+        sharedState->allCreatedObjects.push_back(qmlObject);
+
         if (!populateInstance(binding->value.objectIndex, qmlObject, qmlObject,
                               /*value type property*/ nullptr, binding))
             return false;
@@ -1051,7 +1056,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProper
                 if (!qmlBinding->setTarget(bindingTarget, *targetProperty, subprop) && targetProperty->isAlias())
                     return false;
 
-                sharedState->allCreatedBindings.push(qmlBinding);
+                sharedState->allCreatedBindings.push_back(qmlBinding);
 
                 if (bindingProperty->isAlias()) {
                     QQmlPropertyPrivate::setBinding(qmlBinding.data(), QQmlPropertyPrivate::DontEnable);
@@ -1289,7 +1294,11 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
     QObject *instance = nullptr;
     QQmlData *ddata = nullptr;
     QQmlCustomParser *customParser = nullptr;
+
     QQmlParserStatus *parserStatus = nullptr;
+    int parserStatusCast = 0;
+    int instanceIndex = 0;
+
     bool installPropertyCache = true;
 
     if (obj->hasFlag(QV4::CompiledData::Object::IsComponent)) {
@@ -1317,7 +1326,8 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
                 auto hook = reinterpret_cast<QQmlFinalizerHook *>(reinterpret_cast<char *>(instance) + finalizerCast);
                 sharedState->finalizeHooks.push_back(hook);
             }
-            const int parserStatusCast = type.parserStatusCast();
+
+            parserStatusCast = type.parserStatusCast();
             if (parserStatusCast != -1)
                 parserStatus = reinterpret_cast<QQmlParserStatus*>(reinterpret_cast<char *>(instance) + parserStatusCast);
 
@@ -1329,7 +1339,8 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
                 sharedState->rootContext->setRootObjectInCreation(false);
             }
 
-            sharedState->allCreatedObjects.push(instance);
+            instanceIndex = sharedState->allCreatedObjects.size();
+            sharedState->allCreatedObjects.push_back(instance);
         } else {
             auto compilationUnit = typeRef->compilationUnit();
             Q_ASSERT(compilationUnit);
@@ -1408,8 +1419,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
         // push() the profiler state here, together with the parserStatus, as we'll pop() them
         // together, too.
         Q_QML_OC_PROFILE(sharedState->profiler, sharedState->profiler.push(obj));
-        sharedState->allParserStatusCallbacks.push(parserStatus);
-        parserStatus->d = &sharedState->allParserStatusCallbacks.top();
+        sharedState->allParserStatusCallbacks.push_back({ instanceIndex, parserStatusCast });
     }
 
     // Register the context object in the context early on in order for pending binding
@@ -1505,8 +1515,9 @@ bool QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interrupt)
        way for it to change its value afterwards from that point on.
     */
 
-    while (!sharedState->allCreatedBindings.isEmpty()) {
-        QQmlAbstractBinding::Ptr b = sharedState->allCreatedBindings.pop();
+    while (!sharedState->allCreatedBindings.empty()) {
+        QQmlAbstractBinding::Ptr b = sharedState->allCreatedBindings.back();
+        sharedState->allCreatedBindings.pop_back();
         Q_ASSERT(b);
         // skip, if b is not added to an object
         if (!b->isAddedToObject())
@@ -1567,14 +1578,19 @@ bool QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interrupt)
     }
 
     if (QQmlVME::componentCompleteEnabled()) { // the qml designer does the component complete later
-        while (!sharedState->allParserStatusCallbacks.isEmpty()) {
+        while (!sharedState->allParserStatusCallbacks.empty()) {
             QQmlObjectCompletionProfiler profiler(&sharedState->profiler);
-            QQmlParserStatus *status = sharedState->allParserStatusCallbacks.pop();
+            const ParserStatus status = sharedState->allParserStatusCallbacks.back();
+            sharedState->allParserStatusCallbacks.pop_back();
 
-            if (status && status->d) {
-                status->d = nullptr;
-                status->componentComplete();
-            }
+            const QQmlGuard<QObject> &instance = sharedState->allCreatedObjects[status.objectIndex];
+            if (!instance)
+                continue;
+
+            QQmlParserStatus *parserStatus
+                    = reinterpret_cast<QQmlParserStatus *>(
+                            reinterpret_cast<char *>(instance.data()) + status.parserStatusCast);
+            parserStatus->componentComplete();
 
             if (watcher.hasRecursed() || interrupt.shouldInterrupt())
                 return false;
@@ -1613,8 +1629,9 @@ void QQmlObjectCreator::clear()
         return;
     Q_ASSERT(phase != Startup);
 
-    while (!sharedState->allCreatedObjects.isEmpty()) {
-        auto object = sharedState->allCreatedObjects.pop();
+    while (!sharedState->allCreatedObjects.empty()) {
+        auto object = sharedState->allCreatedObjects.back();
+        sharedState->allCreatedObjects.pop_back();
         if (engine->objectOwnership(object) != QQmlEngine::CppOwnership) {
             delete object;
         }
@@ -1852,12 +1869,12 @@ QQmlObjectCreatorRecursionWatcher::QQmlObjectCreatorRecursionWatcher(QQmlObjectC
 
 void ObjectInCreationGCAnchorList::trackObject(QV4::ExecutionEngine *engine, QObject *instance)
 {
-    *allJavaScriptObjects = QV4::QObjectWrapper::wrap(engine, instance);
+    QV4::Value *wrapper = allocationScope->alloc<QV4::Scope::Uninitialized>();
+    *wrapper = QV4::QObjectWrapper::wrap(engine, instance);
     // we have to handle the case where the gc is already running, but the scope is discarded
     // before the collector runs again. In that case, rescanning won't help us. Thus, mark the
     // object.
-    QV4::WriteBarrier::markCustom(engine, [this](QV4::MarkStack *ms) {
-        allJavaScriptObjects->heapObject()->mark(ms);
+    QV4::WriteBarrier::markCustom(engine, [wrapper](QV4::MarkStack *ms) {
+        wrapper->heapObject()->mark(ms);
     });
-    ++allJavaScriptObjects;
 }
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index eb0c7aa09a..ba940f0acf 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -17,7 +17,6 @@
 #include <private/qqmlimport_p.h>
 #include <private/qqmltypenamecache_p.h>
 #include <private/qv4compileddata_p.h>
-#include <private/qfinitestack_p.h>
 #include <private/qrecursionwatcher_p.h>
 #include <private/qqmlprofiler_p.h>
 #include <private/qv4qmlcontext_p.h>
@@ -99,23 +98,29 @@ class ObjectInCreationGCAnchorList {
 public:
     // this is a non owning view, rule of zero applies
     ObjectInCreationGCAnchorList() = default;
-    ObjectInCreationGCAnchorList(const QV4::Scope &scope, int totalObjectCount)
+    ObjectInCreationGCAnchorList(const QV4::Scope &scope)
     {
-        allJavaScriptObjects = scope.alloc(totalObjectCount);
+        allocationScope = &scope;
     }
     void trackObject(QV4::ExecutionEngine *engine, QObject *instance);
-    bool canTrack() const { return allJavaScriptObjects; }
+    bool canTrack() const { return allocationScope; }
 private:
-    QV4::Value *allJavaScriptObjects = nullptr; // pointer to vector on JS stack to reference JS wrappers during creation phase.
+    // pointer to scope to reference JS wrappers during creation phase.
+    const QV4::Scope *allocationScope = nullptr;
+};
+
+struct ParserStatus {
+    int objectIndex = 0;
+    int parserStatusCast = 0;
 };
 
 struct QQmlObjectCreatorSharedState final : QQmlRefCounted<QQmlObjectCreatorSharedState>
 {
     QQmlRefPointer<QQmlContextData> rootContext;
     QQmlRefPointer<QQmlContextData> creationContext;
-    QFiniteStack<QQmlAbstractBinding::Ptr> allCreatedBindings;
-    QFiniteStack<QQmlParserStatus*> allParserStatusCallbacks;
-    QFiniteStack<QQmlGuard<QObject> > allCreatedObjects;
+    std::vector<QQmlAbstractBinding::Ptr> allCreatedBindings;
+    std::vector<ParserStatus> allParserStatusCallbacks;
+    std::vector<QQmlGuard<QObject>> allCreatedObjects;
     ObjectInCreationGCAnchorList allJavaScriptObjects; // pointer to vector on JS stack to reference JS wrappers during creation phase.
     QQmlComponentAttached *componentAttached;
     QList<QQmlFinalizerHook *> finalizeHooks;
@@ -164,7 +169,7 @@ public:
     {
         return parentContext.contextData();
     }
-    QFiniteStack<QQmlGuard<QObject> > &allCreatedObjects() { return sharedState->allCreatedObjects; }
+    std::vector<QQmlGuard<QObject> > &allCreatedObjects() { return sharedState->allCreatedObjects; }
 
     RequiredProperties *requiredProperties() {return &sharedState->requiredProperties;}
     bool componentHadTopLevelRequiredProperties() const {return sharedState->hadTopLevelRequiredProperties;}
@@ -285,8 +290,7 @@ private:
 
         QV4::Scope valueScope(v4);
         QScopedValueRollback<ObjectInCreationGCAnchorList> jsObjectGuard(
-                sharedState->allJavaScriptObjects,
-                ObjectInCreationGCAnchorList(valueScope, compilationUnit->totalObjectCount(m_inlineComponentName)));
+                sharedState->allJavaScriptObjects, ObjectInCreationGCAnchorList(valueScope));
 
         Q_ASSERT(topLevelCreator);
         QV4::QmlContext *qmlContext = static_cast<QV4::QmlContext *>(valueScope.alloc());
diff --git a/src/qml/qml/qqmlparserstatus.cpp b/src/qml/qml/qqmlparserstatus.cpp
index 522b829e68..e1562e8415 100644
--- a/src/qml/qml/qqmlparserstatus.cpp
+++ b/src/qml/qml/qqmlparserstatus.cpp
@@ -37,16 +37,13 @@ QT_BEGIN_NAMESPACE
 
 /*! \internal */
 QQmlParserStatus::QQmlParserStatus()
-: d(nullptr)
+: d(0)
 {
+    Q_UNUSED(d);
 }
 
 /*! \internal */
-QQmlParserStatus::~QQmlParserStatus()
-{
-    if(d)
-        (*d) = nullptr;
-}
+QQmlParserStatus::~QQmlParserStatus() = default;
 
 /*!
     \fn void QQmlParserStatus::classBegin()
diff --git a/src/qml/qml/qqmlparserstatus.h b/src/qml/qml/qqmlparserstatus.h
index 9cfb544358..4443d717db 100644
--- a/src/qml/qml/qqmlparserstatus.h
+++ b/src/qml/qml/qqmlparserstatus.h
@@ -20,11 +20,7 @@ public:
     virtual void componentComplete()=0;
 
 private:
-    friend class QQmlComponent;
-    friend class QQmlComponentPrivate;
-    friend class QQmlEnginePrivate;
-    friend class QQmlObjectCreator;
-    QQmlParserStatus **d;
+    quintptr d;
 };
 
 #define QQmlParserStatus_iid "org.qt-project.Qt.QQmlParserStatus"
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index 3b9bf80940..e4cfefbe3c 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -5,7 +5,6 @@
 
 #include <private/qmetaobjectbuilder_p.h>
 #include "qqmlengine.h"
-#include <private/qfinitestack_p.h>
 #include <QtQml/private/qqmlcomponent_p.h>
 
 #include <QStack>
@@ -52,8 +51,8 @@ void QQmlVMEGuard::guard(QQmlObjectCreator *creator)
 {
     clear();
 
-    QFiniteStack<QQmlGuard<QObject> > &objects = creator->allCreatedObjects();
-    m_objectCount = objects.count();
+    std::vector<QQmlGuard<QObject>> &objects = creator->allCreatedObjects();
+    m_objectCount = objects.size();
     m_objects = new QQmlGuard<QObject>[m_objectCount];
     for (int ii = 0; ii < m_objectCount; ++ii)
         m_objects[ii] = objects[ii];
diff --git a/src/qml/qml/qqmlvme_p.h b/src/qml/qml/qqmlvme_p.h
index b8dfc28050..e50a05edb0 100644
--- a/src/qml/qml/qqmlvme_p.h
+++ b/src/qml/qml/qqmlvme_p.h
@@ -25,7 +25,6 @@
 #include <QtCore/qtypeinfo.h>
 
 #include <private/qqmlengine_p.h>
-#include <private/qfinitestack_p.h>
 
 #include <atomic>
 
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
index 2088f958ae..6b132ed5fa 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -635,15 +635,18 @@ void tst_QQmlProfilerService::signalSourceLocation()
     checkTraceReceived();
     checkJsHeap();
 
-    auto createType = [](int line, int column) {
+    auto createType = [](int line, int column, RangeType rangeType = HandlingSignal) {
         return QQmlProfilerEventType(
-                    MaximumMessage, HandlingSignal, -1,
+                    MaximumMessage, rangeType, -1,
                     QQmlProfilerEventLocation(QLatin1String("signalSourceLocation.qml"), line,
                                               column));
     };
 
-    VERIFY(MessageListQML, 4, createType(8, 5), CheckType | CheckNumbers, m_rangeStart);
-    VERIFY(MessageListQML, 6, createType(7, 5), CheckType | CheckNumbers, m_rangeEnd);
+    // Creating the attached object
+    VERIFY(MessageListQML, 3, createType(8, 5, Creating), CheckType | CheckNumbers, m_rangeStart);
+
+    VERIFY(MessageListQML, 6, createType(8, 5), CheckType | CheckNumbers, m_rangeStart);
+    VERIFY(MessageListQML, 8, createType(7, 5), CheckType | CheckNumbers, m_rangeEnd);
 }
 
 void tst_QQmlProfilerService::javascript()
diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
index 948dc66e71..b1e1a8c8db 100644
--- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
+++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
@@ -1112,7 +1112,7 @@ void tst_qqmlincubator::selfDelete()
     // We have to cheat and manually remove it from the creator->allCreatedObjects
     // otherwise we will do a double delete
     QQmlIncubatorPrivate *incubatorPriv = QQmlIncubatorPrivate::get(incubator);
-    incubatorPriv->creator->allCreatedObjects().pop();
+    incubatorPriv->creator->allCreatedObjects().pop_back();
     delete SelfRegisteringType::me();
 
     {
