diff options
author | Simon Hausmann <[email protected]> | 2014-06-21 10:56:00 +0200 |
---|---|---|
committer | Simon Hausmann <[email protected]> | 2014-06-23 12:34:51 +0200 |
commit | 714d9d95484907378b46292df7aec0832f557f1d (patch) | |
tree | a2fa6446a723bcb79d68cfcb3d5dd715ccc9b084 | |
parent | fca40e7cf81338e4c22ef25fa0b3fe0f691632b7 (diff) |
Fix memory leak in QQmlComponent::createObject
Regression introduced with 5.3.0. Prevent the leak of the object creator
on repeated createObject calls by using a scoped pointer.
Change-Id: Ib4fe7c9c6926c2390f7ae78f3287bb7da5f60527
Task-number: QTBUG-39742
Reviewed-by: Lars Knoll <[email protected]>
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent_p.h | 6 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index e9a3449a22..1da2f1c109 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -880,7 +880,7 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context) enginePriv->referenceScarceResources(); QObject *rv = 0; - state.creator = new QQmlObjectCreator(context, cc, creationContext); + state.creator.reset(new QQmlObjectCreator(context, cc, creationContext)); rv = state.creator->create(start); if (!rv) state.errors = state.creator->errors; @@ -920,7 +920,7 @@ void QQmlComponentPrivate::beginDeferred(QQmlEnginePrivate *enginePriv, Q_ASSERT(ddata->deferredData); QQmlData::DeferredData *deferredData = ddata->deferredData; QQmlContextData *creationContext = 0; - state->creator = new QQmlObjectCreator(deferredData->context->parent, deferredData->compiledData, creationContext); + state->creator.reset(new QQmlObjectCreator(deferredData->context->parent, deferredData->compiledData, creationContext)); if (!state->creator->populateDeferredProperties(object)) state->errors << state->creator->errors; } diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h index e8ae540148..2c70d7b100 100644 --- a/src/qml/qml/qqmlcomponent_p.h +++ b/src/qml/qml/qqmlcomponent_p.h @@ -106,15 +106,13 @@ public: struct ConstructionState { ConstructionState() - : creator(0) - , completePending(false) + : completePending(false) {} ~ConstructionState() { - delete creator; } - QQmlObjectCreator *creator; + QScopedPointer<QQmlObjectCreator> creator; QList<QQmlError> errors; bool completePending; }; |