diff options
author | Richard Weickelt <richard@weickelt.de> | 2018-05-15 12:28:41 +0200 |
---|---|---|
committer | Richard Weickelt <richard@weickelt.de> | 2018-05-18 09:29:26 +0000 |
commit | d33d5a40483c6b56c3be19ce244f14938a5941a0 (patch) | |
tree | fdc7a803067b976ccf24470ee9288238806e1667 /src/qml/qml/qqmlcomponent.cpp | |
parent | 38dc69ae01d2ba733fb35f7c8d26500062858798 (diff) |
Allow partial creation of more than 10 QQmlComponent instances
The recursion detection in QQmlComponent erroneously triggered when
calling beginCreate() on >= 10 different instances. This may happen by
intention and is not necessarily a sign of recursion.
Since beginCreate() does never invoke a potentially nested
Qt.createComponent(), but completeCreate() does, it is better to
modify the creationDepth counter in completeCreate(). This also leads
to simpler code.
The test, however, can remain in beginCreate().
Task-number: QTBUG-47633
Change-Id: If413a8b08421d321d6a426ec16600996cb3f6ea1
Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au>
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlcomponent.cpp')
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 1802932f45..22e20de8d7 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -845,13 +845,10 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context) // Do not create infinite recursion in object creation static const int maxCreationDepth = 10; - if (++creationDepth.localData() >= maxCreationDepth) { + if (creationDepth.localData() >= maxCreationDepth) { qWarning("QQmlComponent: Component creation is recursing - aborting"); - --creationDepth.localData(); return nullptr; } - Q_ASSERT(creationDepth.localData() >= 1); - depthIncreased = true; QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(engine); @@ -875,10 +872,6 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context) ddata->indestructible = true; ddata->explicitIndestructibleSet = true; ddata->rootObjectInCreation = false; - } else { - Q_ASSERT(creationDepth.localData() >= 1); - --creationDepth.localData(); - depthIncreased = false; } return rv; @@ -952,14 +945,10 @@ void QQmlComponent::completeCreate() void QQmlComponentPrivate::completeCreate() { if (state.completePending) { + ++creationDepth.localData(); QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); complete(ep, &state); - } - - if (depthIncreased) { - Q_ASSERT(creationDepth.localData() >= 1); --creationDepth.localData(); - depthIncreased = false; } } |