aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2017-11-06 16:13:13 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2017-11-30 07:35:35 +0000
commit60d589ccddb036e84883a6c2ef63a5292c8ad022 (patch)
treed0615d751ed79e73a9f1ac7938831e144c513a81 /tests
parent8bdf33051aa679db1f060314c6ccab1cb9a77a7a (diff)
QQmlIntanceModel: use QQmlIncubator::IncubationMode instead of bool to specify incubation mode
The current implementation would pass a boolean to signal if asynchronous or synchronous incubation should be used to create an item. The problem with this approach is that passing 'synchronous" would translate to QQmlIncubation::AsynchronousIfNested later down the chain. This meant that even if the caller requested synchronous incubation, it could end up with asynchronous incubation anyway, e.g if an async parent incubator was active at the time of the call. And this can easily come as an unhandled supprise for the caller, and as such, cause unforseen bugs. This patch is a first of a set of patches that is done to fix the bug reported in the task below. It will not change any behavior, it is written to preserve the logic exactly as it were, just as a preparation for subsequent patches. It makes it explicit at the call location what incubation mode will be used, and especially make it clear whenever the AsynchronousIfNested flag is in play. Task-number: QTBUG-61537 Change-Id: I8b3ba5438ebb2cd59983a098bd8ceeeb844da87b Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
index cabfb97914..2280f75518 100644
--- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
+++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
@@ -4013,7 +4013,7 @@ void tst_qquickvisualdatamodel::asynchronousInsert()
connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*)));
connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*)));
- QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true));
+ QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, QQmlIncubator::Asynchronous));
QVERIFY(!item);
QVERIFY(!requester.itemInitialized);
@@ -4025,7 +4025,7 @@ void tst_qquickvisualdatamodel::asynchronousInsert()
newItems.append(qMakePair(QLatin1String("New item") + QString::number(i), QString(QLatin1String(""))));
model.insertItems(insertIndex, newItems);
- item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false));
+ item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex));
QVERIFY(item);
QCOMPARE(requester.itemInitialized, item);
@@ -4078,7 +4078,7 @@ void tst_qquickvisualdatamodel::asynchronousRemove()
connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*)));
connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*)));
- QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true));
+ QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, QQmlIncubator::Asynchronous));
QVERIFY(!item);
QVERIFY(!requester.itemInitialized);
@@ -4099,7 +4099,7 @@ void tst_qquickvisualdatamodel::asynchronousRemove()
QVERIFY(!requester.itemCreated);
QVERIFY(!requester.itemDestroyed);
} else {
- item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false));
+ item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex));
QVERIFY(item);
QCOMPARE(requester.itemInitialized, item);
@@ -4157,7 +4157,7 @@ void tst_qquickvisualdatamodel::asynchronousMove()
connect(visualModel, SIGNAL(createdItem(int,QObject*)), &requester, SLOT(createdItem(int,QObject*)));
connect(visualModel, SIGNAL(destroyingItem(QObject*)), &requester, SLOT(destroyingItem(QObject*)));
- QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true));
+ QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, QQmlIncubator::Asynchronous));
QVERIFY(!item);
QVERIFY(!requester.itemInitialized);
@@ -4166,7 +4166,7 @@ void tst_qquickvisualdatamodel::asynchronousMove()
model.moveItems(from, to, count);
- item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false));
+ item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex));
QVERIFY(item);
@@ -4200,7 +4200,7 @@ void tst_qquickvisualdatamodel::asynchronousCancel()
QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create());
QVERIFY(visualModel);
- QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, true));
+ QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(requestIndex, QQmlIncubator::Asynchronous));
QVERIFY(!item);
QCOMPARE(controller.incubatingObjectCount(), 1);
@@ -4225,7 +4225,7 @@ void tst_qquickvisualdatamodel::invalidContext()
QQmlDelegateModel *visualModel = qobject_cast<QQmlDelegateModel*>(c.create(context.data()));
QVERIFY(visualModel);
- QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(4, false));
+ QQuickItem *item = qobject_cast<QQuickItem*>(visualModel->object(4));
QVERIFY(item);
visualModel->release(item);
@@ -4233,7 +4233,7 @@ void tst_qquickvisualdatamodel::invalidContext()
model.insertItem(4, "new item", "");
- item = qobject_cast<QQuickItem*>(visualModel->object(4, false));
+ item = qobject_cast<QQuickItem*>(visualModel->object(4));
QVERIFY(!item);
}