aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcomponent
diff options
context:
space:
mode:
authorRichard Weickelt <richard@weickelt.de>2018-05-15 12:28:41 +0200
committerRichard Weickelt <richard@weickelt.de>2018-05-18 09:29:26 +0000
commitd33d5a40483c6b56c3be19ce244f14938a5941a0 (patch)
treefdc7a803067b976ccf24470ee9288238806e1667 /tests/auto/qml/qqmlcomponent
parent38dc69ae01d2ba733fb35f7c8d26500062858798 (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 'tests/auto/qml/qqmlcomponent')
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
index 6a0dc28ca4..0263115db8 100644
--- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -116,6 +116,7 @@ private slots:
void onDestructionCount();
void recursion();
void recursionContinuation();
+ void partialComponentCreation();
void callingContextForInitialProperties();
void relativeUrl_data();
void relativeUrl();
@@ -526,6 +527,29 @@ void tst_qqmlcomponent::recursionContinuation()
QVERIFY(object->property("success").toBool());
}
+void tst_qqmlcomponent::partialComponentCreation()
+{
+ const int maxCount = 17;
+ QQmlEngine engine;
+ QScopedPointer<QQmlComponent> components[maxCount];
+ QScopedPointer<QObject> objects[maxCount];
+ QQmlTestMessageHandler messageHandler;
+
+ QCOMPARE(engine.outputWarningsToStandardError(), true);
+
+ for (int i = 0; i < maxCount; i++) {
+ components[i].reset(new QQmlComponent(&engine, testFileUrl("QtObjectComponent.qml")));
+ objects[i].reset(components[i]->beginCreate(engine.rootContext()));
+ QVERIFY(objects[i].isNull() == false);
+ }
+ QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString()));
+
+ for (int i = 0; i < maxCount; i++) {
+ components[i]->completeCreate();
+ }
+ QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString()));
+}
+
class CallingContextCheckingClass : public QObject
{
Q_OBJECT