diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-10-29 15:42:21 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-11-01 09:20:59 +0100 |
commit | 891072f3f5f8f988d4da6c39ab654b605e25dda7 (patch) | |
tree | f28b1623cbaa1e017e591775be13755a3ef76847 /src/qml/qml/qqmlcomponent_p.h | |
parent | d00c76171de0c76794eb70a7284326332c0b3c66 (diff) |
QQmlComponent: Make it harder to leak deferred states
The previous pointer wrangling was ripe with foot guns. Let's just use a
vector of unique_ptr to keep track of the states.
Change-Id: I3ae225b3ab8644aa690d506d0a5de0bfb9ecce23
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlcomponent_p.h')
-rw-r--r-- | src/qml/qml/qqmlcomponent_p.h | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h index 59ef47f2c3..f95e83f15e 100644 --- a/src/qml/qml/qqmlcomponent_p.h +++ b/src/qml/qml/qqmlcomponent_p.h @@ -112,27 +112,13 @@ public: QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit; struct ConstructionState { - ConstructionState() - : completePending(false) - {} - ~ConstructionState() - { - } - - QScopedPointer<QQmlObjectCreator> creator; + std::unique_ptr<QQmlObjectCreator> creator; QList<QQmlError> errors; - bool completePending; + bool completePending = false; }; ConstructionState state; - struct DeferredState { - ~DeferredState() { - qDeleteAll(constructionStates); - constructionStates.clear(); - } - QVector<ConstructionState *> constructionStates; - }; - + using DeferredState = std::vector<ConstructionState>; static void beginDeferred(QQmlEnginePrivate *enginePriv, QObject *object, DeferredState* deferredState); static void completeDeferred(QQmlEnginePrivate *enginePriv, DeferredState *deferredState); |