aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-03-24 01:00:15 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-03-24 01:00:15 +0100
commit73894987a22c9821c508c921f38a0db442559c71 (patch)
tree15182a0090157a9b6621e2688ca6b44963962ee6
parent8aa13799516bb412908a5612da5ea5ba0972b998 (diff)
parent861f53d60cc2dd8bd8529c65863af881dbdd8db8 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp8
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp2
-rw-r--r--src/qmlmodels/qqmldelegatemodel.cpp23
-rw-r--r--src/quick/items/qquicktableview.cpp41
-rw-r--r--src/quick/items/qquicktableview_p_p.h4
-rw-r--r--src/quick/items/qquickview.cpp6
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp248
-rw-r--r--tests/auto/quick/qquickrendercontrol/data/rect.qml47
-rw-r--r--tests/auto/quick/qquickrendercontrol/qquickrendercontrol.pro12
-rw-r--r--tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp202
-rw-r--r--tests/auto/quick/quick.pro3
-rw-r--r--tests/auto/quick/shared/viewtestutil.cpp18
12 files changed, 438 insertions, 176 deletions
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index d367edad1b..d10fad191c 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -194,8 +194,8 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, QObject *obj
r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
auto valueType = QQmlValueTypeFactory::valueType(typeId);
if (!valueType) {
- QMetaType metaType(typeId);
- return engine->throwTypeError(QLatin1String("Type %1 is not a value type").arg(metaType.name()));
+ return engine->throwTypeError(QLatin1String("Type %1 is not a value type")
+ .arg(QString::fromUtf8(QMetaType(typeId).name())));
}
r->d()->setValueType(valueType);
r->d()->setGadgetPtr(nullptr);
@@ -211,8 +211,8 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, const QVaria
r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
auto valueType = QQmlValueTypeFactory::valueType(typeId);
if (!valueType) {
- QMetaType metaType(typeId);
- return engine->throwTypeError(QLatin1String("Type %1 is not a value type").arg(metaType.name()));
+ return engine->throwTypeError(QLatin1String("Type %1 is not a value type")
+ .arg(QString::fromUtf8(QMetaType(typeId).name())));
}
r->d()->setValueType(valueType);
r->d()->setGadgetPtr(nullptr);
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 179d5314a8..416aca8667 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -1291,7 +1291,7 @@ void QQmlXMLHttpRequest::requestFromUrl(const QUrl &url)
} else {
QObject::connect(m_network, SIGNAL(readyRead()),
this, SLOT(readyRead()));
- QObject::connect(m_network, SIGNAL(error(QNetworkReply::NetworkError)),
+ QObject::connect(m_network, SIGNAL(errorOccurred(QNetworkReply::NetworkError)),
this, SLOT(error(QNetworkReply::NetworkError)));
QObject::connect(m_network, SIGNAL(finished()),
this, SLOT(finished()));
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp
index 710cc359b4..646ac5e9f9 100644
--- a/src/qmlmodels/qqmldelegatemodel.cpp
+++ b/src/qmlmodels/qqmldelegatemodel.cpp
@@ -269,13 +269,23 @@ QQmlDelegateModel::~QQmlDelegateModel()
cacheItem->contextData->invalidate();
cacheItem->contextData = nullptr;
cacheItem->scriptRef -= 1;
+ } else if (cacheItem->incubationTask) {
+ // Both the incubationTask and the object may hold a scriptRef,
+ // but if both are present, only one scriptRef is held in total.
+ cacheItem->scriptRef -= 1;
}
+
cacheItem->groups &= ~Compositor::UnresolvedFlag;
cacheItem->objectRef = 0;
+
+ if (cacheItem->incubationTask) {
+ d->releaseIncubator(cacheItem->incubationTask);
+ cacheItem->incubationTask->vdm = nullptr;
+ cacheItem->incubationTask = nullptr;
+ }
+
if (!cacheItem->isReferenced())
delete cacheItem;
- else if (cacheItem->incubationTask)
- cacheItem->incubationTask->vdm = nullptr;
}
}
@@ -641,7 +651,7 @@ QQmlDelegateModel::ReleaseFlags QQmlDelegateModel::release(QObject *item, QQmlIn
void QQmlDelegateModel::cancel(int index)
{
Q_D(QQmlDelegateModel);
- if (!d->m_delegate || index < 0 || index >= d->m_compositor.count(d->m_compositorGroup)) {
+ if (index < 0 || index >= d->m_compositor.count(d->m_compositorGroup)) {
qWarning() << "DelegateModel::cancel: index out range" << index << d->m_compositor.count(d->m_compositorGroup);
return;
}
@@ -936,15 +946,18 @@ void PropertyUpdater::breakBinding()
return;
if (updateCount == 0) {
QObject::disconnect(*it);
+ senderToConnection.erase(it);
QQmlError warning;
- warning.setUrl(qmlContext(QObject::sender())->baseUrl());
+ if (auto context = qmlContext(QObject::sender()))
+ warning.setUrl(context->baseUrl());
+ else
+ return;
auto signalName = QString::fromLatin1(QObject::sender()->metaObject()->method(QObject::senderSignalIndex()).name());
signalName.chop(sizeof("changed")-1);
QString propName = signalName;
propName[0] = propName[0].toLower();
warning.setDescription(QString::fromUtf8("Writing to \"%1\" broke the binding to the underlying model").arg(propName));
qmlWarning(this, warning);
- senderToConnection.erase(it);
} else {
--updateCount;
}
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 9b1704421c..cb600c7b47 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -493,20 +493,34 @@ QQuickTableViewAttached *QQuickTableViewPrivate::getAttachedObject(const QObject
int QQuickTableViewPrivate::modelIndexAtCell(const QPoint &cell) const
{
- int availableRows = tableSize.height();
- int modelIndex = cell.y() + (cell.x() * availableRows);
- Q_TABLEVIEW_ASSERT(modelIndex < model->count(),
- "modelIndex:" << modelIndex << "cell:" << cell << "count:" << model->count());
- return modelIndex;
+ // QQmlTableInstanceModel expects index to be in column-major
+ // order. This means that if the view is transposed (with a flipped
+ // width and height), we need to calculate it in row-major instead.
+ if (isTransposed) {
+ int availableColumns = tableSize.width();
+ return (cell.y() * availableColumns) + cell.x();
+ } else {
+ int availableRows = tableSize.height();
+ return (cell.x() * availableRows) + cell.y();
+ }
}
QPoint QQuickTableViewPrivate::cellAtModelIndex(int modelIndex) const
{
- int availableRows = tableSize.height();
- Q_TABLEVIEW_ASSERT(availableRows > 0, availableRows);
- int column = int(modelIndex / availableRows);
- int row = modelIndex % availableRows;
- return QPoint(column, row);
+ // QQmlTableInstanceModel expects index to be in column-major
+ // order. This means that if the view is transposed (with a flipped
+ // width and height), we need to calculate it in row-major instead.
+ if (isTransposed) {
+ int availableColumns = tableSize.width();
+ int row = int(modelIndex / availableColumns);
+ int column = modelIndex % availableColumns;
+ return QPoint(column, row);
+ } else {
+ int availableRows = tableSize.height();
+ int column = int(modelIndex / availableRows);
+ int row = modelIndex % availableRows;
+ return QPoint(column, row);
+ }
}
int QQuickTableViewPrivate::edgeToArrayIndex(Qt::Edge edge)
@@ -1234,12 +1248,13 @@ void QQuickTableViewPrivate::updateTableSize()
QSize QQuickTableViewPrivate::calculateTableSize()
{
+ QSize size(0, 0);
if (tableModel)
- return QSize(tableModel->columns(), tableModel->rows());
+ size = QSize(tableModel->columns(), tableModel->rows());
else if (model)
- return QSize(1, model->count());
+ size = QSize(1, model->count());
- return QSize(0, 0);
+ return isTransposed ? size.transposed() : size;
}
qreal QQuickTableViewPrivate::getColumnLayoutWidth(int column)
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index a3cc39419f..93a8d839e0 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -278,6 +278,10 @@ public:
bool inSyncViewportPosRecursive = false;
bool inUpdateContentSize = false;
+ // isTransposed is currently only used by HeaderView.
+ // Consider making it public.
+ bool isTransposed = false;
+
QJSValue rowHeightProvider;
QJSValue columnWidthProvider;
QQuickTableSectionSizeProvider rowHeights;
diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp
index 84488dcaca..5b3b954460 100644
--- a/src/quick/items/qquickview.cpp
+++ b/src/quick/items/qquickview.cpp
@@ -486,7 +486,9 @@ void QQuickView::continueExecute()
return;
}
- QObject *obj = d->initialProperties.empty() ? d->component->create() : d->component->createWithInitialProperties(d->initialProperties);
+ QScopedPointer<QObject> obj(d->initialProperties.empty()
+ ? d->component->create()
+ : d->component->createWithInitialProperties(d->initialProperties));
if (d->component->isError()) {
const QList<QQmlError> errorList = d->component->errors();
@@ -498,7 +500,7 @@ void QQuickView::continueExecute()
return;
}
- d->setRootObject(obj);
+ d->setRootObject(obj.take());
emit statusChanged(status());
}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 49b68a8473..4e49344bc0 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -433,8 +433,8 @@ void tst_QQuickListView::items(const QUrl &source)
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(source);
qApp->processEvents();
@@ -498,8 +498,6 @@ void tst_QQuickListView::items(const QUrl &source)
QTRY_COMPARE(listview->highlightResizeVelocity(), 1000.0);
QTRY_COMPARE(listview->highlightMoveVelocity(), 100000.0);
-
- delete testObject;
}
@@ -516,8 +514,8 @@ void tst_QQuickListView::changed(const QUrl &source)
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(source);
qApp->processEvents();
@@ -539,8 +537,6 @@ void tst_QQuickListView::changed(const QUrl &source)
QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != nullptr);
QTRY_COMPARE(number->text(), model.number(1));
-
- delete testObject;
}
template <class T>
@@ -558,8 +554,8 @@ void tst_QQuickListView::inserted(const QUrl &source)
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(source);
qApp->processEvents();
@@ -636,8 +632,6 @@ void tst_QQuickListView::inserted(const QUrl &source)
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
QVERIFY(item);
QTRY_COMPARE(item->y() - listview->contentY(), 0.);
-
- delete testObject;
}
template <class T>
@@ -656,8 +650,8 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("listviewtest.qml"));
window->show();
@@ -715,7 +709,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
break;
}
}
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+ QVERIFY2(firstVisibleIndex >= 0, QByteArray::number(firstVisibleIndex));
// Confirm items positioned correctly and indexes correct
QQuickText *name;
@@ -724,14 +718,14 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
const qreal visibleToPos = listview->contentY() + listview->height() + listview->displayMarginEnd() + listview->cacheBuffer();
for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
qreal pos = i*20.0 + itemsOffsetAfterMove;
if (verticalLayoutDirection == QQuickItemView::BottomToTop)
pos = -item->height() - pos;
// Items outside the visible area (including cache buffer) should be skipped
if (pos > visibleToPos || pos < visibleFromPos) {
QTRY_VERIFY2(QQuickItemPrivate::get(item)->culled || item->y() < visibleFromPos || item->y() > visibleToPos,
- QTest::toString(QString("index %5, y %1, from %2, to %3, expected pos %4, culled %6").
+ qPrintable(QString("index %5, y %1, from %2, to %3, expected pos %4, culled %6").
arg(item->y()).arg(visibleFromPos).arg(visibleToPos).arg(pos).arg(i).arg(bool(QQuickItemPrivate::get(item)->culled))));
continue;
}
@@ -745,7 +739,6 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
}
releaseView(window);
- delete testObject;
}
void tst_QQuickListView::inserted_more_data()
@@ -851,8 +844,8 @@ void tst_QQuickListView::insertBeforeVisible()
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("listviewtest.qml"));
window->show();
@@ -900,7 +893,7 @@ void tst_QQuickListView::insertBeforeVisible()
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
name = findItem<QQuickText>(contentItem, "textName", i);
QVERIFY(name != nullptr);
@@ -908,7 +901,6 @@ void tst_QQuickListView::insertBeforeVisible()
}
releaseView(window);
- delete testObject;
}
void tst_QQuickListView::insertBeforeVisible_data()
@@ -964,8 +956,8 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(source);
window->show();
@@ -1127,8 +1119,6 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
for (int i = 0; i < 18; ++i)
model.removeItems(model.count() - 1, 1);
QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() > 16);
-
- delete testObject;
}
template <class T>
@@ -1148,8 +1138,8 @@ void tst_QQuickListView::removed_more(const QUrl &source, QQuickItemView::Vertic
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(source);
window->show();
@@ -1191,14 +1181,14 @@ void tst_QQuickListView::removed_more(const QUrl &source, QQuickItemView::Vertic
break;
}
}
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+ QVERIFY2(firstVisibleIndex >= 0, QByteArray::number(firstVisibleIndex));
// Confirm items positioned correctly and indexes correct
QQuickText *name;
QQuickText *number;
for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
qreal pos = i*20.0 + itemsOffsetAfterMove;
if (verticalLayoutDirection == QQuickItemView::BottomToTop)
pos = -item0->height() - pos;
@@ -1212,7 +1202,6 @@ void tst_QQuickListView::removed_more(const QUrl &source, QQuickItemView::Vertic
}
releaseView(window);
- delete testObject;
}
void tst_QQuickListView::removed_more_data()
@@ -1330,8 +1319,8 @@ void tst_QQuickListView::clear(const QUrl &source, QQuickItemView::VerticalLayou
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(source);
window->show();
@@ -1364,8 +1353,6 @@ void tst_QQuickListView::clear(const QUrl &source, QQuickItemView::VerticalLayou
QTRY_COMPARE(listview->count(), 1);
QVERIFY(listview->currentItem() != nullptr);
QCOMPARE(listview->currentIndex(), 0);
-
- delete testObject;
}
template <class T>
@@ -1388,8 +1375,8 @@ void tst_QQuickListView::moved(const QUrl &source, QQuickItemView::VerticalLayou
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(source);
window->show();
@@ -1425,12 +1412,12 @@ void tst_QQuickListView::moved(const QUrl &source, QQuickItemView::VerticalLayou
break;
}
}
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+ QVERIFY2(firstVisibleIndex >= 0, QByteArray::number(firstVisibleIndex));
// Confirm items positioned correctly and indexes correct
for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
qreal pos = i*20.0 + itemsOffsetAfterMove;
if (verticalLayoutDirection == QQuickItemView::BottomToTop)
pos = -item->height() - pos;
@@ -1448,7 +1435,6 @@ void tst_QQuickListView::moved(const QUrl &source, QQuickItemView::VerticalLayou
}
releaseView(window);
- delete testObject;
}
void tst_QQuickListView::moved_data()
@@ -1618,8 +1604,8 @@ void tst_QQuickListView::multipleChanges(bool condensed)
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("listviewtest.qml"));
window->show();
@@ -1671,7 +1657,7 @@ void tst_QQuickListView::multipleChanges(bool condensed)
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
name = findItem<QQuickText>(contentItem, "textName", i);
QVERIFY(name != nullptr);
QTRY_COMPARE(name->text(), model.name(i));
@@ -1680,7 +1666,6 @@ void tst_QQuickListView::multipleChanges(bool condensed)
QTRY_COMPARE(number->text(), model.number(i));
}
- delete testObject;
releaseView(window);
}
@@ -1866,8 +1851,8 @@ void tst_QQuickListView::swapWithFirstItem()
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("listviewtest.qml"));
window->show();
@@ -1881,8 +1866,6 @@ void tst_QQuickListView::swapWithFirstItem()
listview->setContentY(0);
model.moveItem(1, 0);
QTRY_COMPARE(listview->contentY(), qreal(0));
-
- delete testObject;
}
void tst_QQuickListView::checkCountForMultiColumnModels()
@@ -2050,8 +2033,8 @@ void tst_QQuickListView::spacing()
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("listviewtest.qml"));
window->show();
@@ -2095,8 +2078,6 @@ void tst_QQuickListView::spacing()
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.0);
}
-
- delete testObject;
}
template <typename T>
@@ -2823,7 +2804,7 @@ void tst_QQuickListView::currentIndex()
for (int i = 0; i < 30; i++)
initModel.addItem("Item" + QString::number(i), QString::number(i));
- QQuickView *window = new QQuickView(nullptr);
+ QScopedPointer<QQuickView> window(new QQuickView(nullptr));
window->setGeometry(0,0,240,320);
QQmlContext *ctxt = window->rootContext();
@@ -2833,7 +2814,7 @@ void tst_QQuickListView::currentIndex()
QString filename(testFile("listview-initCurrent.qml"));
window->setSource(QUrl::fromLocalFile(filename));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
QTRY_VERIFY(listview != nullptr);
@@ -2921,8 +2902,6 @@ void tst_QQuickListView::currentIndex()
QCOMPARE(QQmlProperty(window->rootObject(), "s").read().toString(), "-1");
QCOMPARE(window->rootObject()->property("currentItemChangedCount").toInt(), 1);
QCOMPARE(listview->currentIndex(), -1);
-
- delete window;
}
void tst_QQuickListView::noCurrentIndex()
@@ -2931,7 +2910,7 @@ void tst_QQuickListView::noCurrentIndex()
for (int i = 0; i < 30; i++)
model.addItem("Item" + QString::number(i), QString::number(i));
- QQuickView *window = new QQuickView(nullptr);
+ QScopedPointer<QQuickView> window(new QQuickView(nullptr));
window->setGeometry(0,0,240,320);
QQmlContext *ctxt = window->rootContext();
@@ -2940,7 +2919,7 @@ void tst_QQuickListView::noCurrentIndex()
QString filename(testFile("listview-noCurrent.qml"));
window->setSource(QUrl::fromLocalFile(filename));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
QTRY_VERIFY(listview != nullptr);
@@ -2959,8 +2938,6 @@ void tst_QQuickListView::noCurrentIndex()
QCOMPARE(listview->currentIndex(), 2);
QVERIFY(listview->highlightItem());
QVERIFY(listview->currentItem());
-
- delete window;
}
void tst_QQuickListView::keyNavigation()
@@ -2978,9 +2955,9 @@ void tst_QQuickListView::keyNavigation()
model.addItem("Item" + QString::number(i), "");
QQuickView *window = getView();
- TestObject *testObject = new TestObject;
+ QScopedPointer<TestObject> testObject(new TestObject);
window->rootContext()->setContextProperty("testModel", &model);
- window->rootContext()->setContextProperty("testObject", testObject);
+ window->rootContext()->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("listviewtest.qml"));
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -3050,7 +3027,6 @@ void tst_QQuickListView::keyNavigation()
QTRY_COMPARE(listview->contentY(), contentPosAtFirstItem.y());
releaseView(window);
- delete testObject;
}
void tst_QQuickListView::keyNavigation_data()
@@ -3192,8 +3168,8 @@ void tst_QQuickListView::cacheBuffer()
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("listviewtest.qml"));
window->show();
@@ -3281,8 +3257,6 @@ void tst_QQuickListView::cacheBuffer()
// negative cache buffer is ignored
listview->setCacheBuffer(-1);
QCOMPARE(listview->cacheBuffer(), 200);
-
- delete testObject;
}
void tst_QQuickListView::positionViewAtBeginningEnd()
@@ -3296,8 +3270,8 @@ void tst_QQuickListView::positionViewAtBeginningEnd()
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->show();
window->setSource(testFileUrl("listviewtest.qml"));
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
@@ -3335,8 +3309,6 @@ void tst_QQuickListView::positionViewAtBeginningEnd()
QTRY_COMPARE(listview->contentY(), -30.);
QVERIFY(listview->highlightItem());
QCOMPARE(listview->highlightItem()->y(), 20.);
-
- delete testObject;
}
void tst_QQuickListView::positionViewAtIndex()
@@ -3356,8 +3328,8 @@ void tst_QQuickListView::positionViewAtIndex()
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->show();
window->setSource(testFileUrl("listviewtest.qml"));
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -3662,7 +3634,7 @@ void tst_QQuickListView::QTBUG_33568()
void tst_QQuickListView::manualHighlight()
{
- QQuickView *window = new QQuickView(nullptr);
+ QScopedPointer<QQuickView> window(new QQuickView(nullptr));
window->setGeometry(0,0,240,320);
QString filename(testFile("manual-highlight.qml"));
@@ -3692,8 +3664,6 @@ void tst_QQuickListView::manualHighlight()
QTRY_COMPARE(listview->currentIndex(), 2);
QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
-
- delete window;
}
void tst_QQuickListView::QTBUG_11105()
@@ -3706,8 +3676,8 @@ void tst_QQuickListView::QTBUG_11105()
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("listviewtest.qml"));
window->show();
@@ -3739,8 +3709,6 @@ void tst_QQuickListView::QTBUG_11105()
itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
QCOMPARE(itemCount, 5);
-
- delete testObject;
}
void tst_QQuickListView::initialZValues()
@@ -4378,8 +4346,8 @@ void tst_QQuickListView::resizeView()
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("listviewtest.qml"));
window->show();
@@ -4442,8 +4410,6 @@ void tst_QQuickListView::resizeView()
QTRY_COMPARE(item->y(), i*20.);
QCOMPARE(delegateVisible(item), i < 6); // inside view visible, outside not visible
}
-
- delete testObject;
}
void tst_QQuickListView::resizeViewAndRepaint()
@@ -4490,8 +4456,8 @@ void tst_QQuickListView::sizeLessThan1()
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("sizelessthan1.qml"));
window->show();
@@ -4511,8 +4477,6 @@ void tst_QQuickListView::sizeLessThan1()
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*0.5);
}
-
- delete testObject;
}
void tst_QQuickListView::QTBUG_14821()
@@ -4623,8 +4587,8 @@ void tst_QQuickListView::resizeFirstDelegate()
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("listviewtest.qml"));
window->show();
@@ -4679,8 +4643,6 @@ void tst_QQuickListView::resizeFirstDelegate()
for (int i=0; i<3; i++) {
QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", i));
}
-
- delete testObject;
}
void tst_QQuickListView::repositionResizedDelegate()
@@ -4832,8 +4794,8 @@ void tst_QQuickListView::indexAt_itemAt()
QQmlContext *ctxt = window->rootContext();
ctxt->setContextProperty("testModel", &model);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("listviewtest.qml"));
window->show();
@@ -4855,7 +4817,6 @@ void tst_QQuickListView::indexAt_itemAt()
QCOMPARE(listview->itemAt(x,y), item);
releaseView(window);
- delete testObject;
}
void tst_QQuickListView::itemAtIndex()
@@ -6486,7 +6447,7 @@ void tst_QQuickListView::unrequestedVisibility()
for (int i = 0; i < 30; i++)
model.addItem("Item" + QString::number(i), QString::number(i));
- QQuickView *window = new QQuickView(nullptr);
+ QScopedPointer<QQuickView> window(new QQuickView(nullptr));
window->setGeometry(0,0,240,320);
QQmlContext *ctxt = window->rootContext();
@@ -6495,7 +6456,7 @@ void tst_QQuickListView::unrequestedVisibility()
window->setSource(testFileUrl("unrequestedItems.qml"));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QQuickListView *leftview;
@@ -6682,8 +6643,6 @@ void tst_QQuickListView::unrequestedVisibility()
item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17);
QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
-
- delete window;
}
void tst_QQuickListView::populateTransitions()
@@ -6704,8 +6663,9 @@ void tst_QQuickListView::populateTransitions()
}
QQuickView *window = getView();
+ QScopedPointer<TestObject> testObject(new TestObject(window->rootContext()));
window->rootContext()->setContextProperty("testModel", &model);
- window->rootContext()->setContextProperty("testObject", new TestObject(window->rootContext()));
+ window->rootContext()->setContextProperty("testObject", testObject.data());
window->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition);
window->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate);
window->rootContext()->setContextProperty("transitionFrom", transitionFrom);
@@ -6736,7 +6696,7 @@ void tst_QQuickListView::populateTransitions()
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->x(), 0.0);
QTRY_COMPARE(item->y(), i*20.0);
QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
@@ -6771,7 +6731,7 @@ void tst_QQuickListView::populateTransitions()
itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->x(), 0.0);
QTRY_COMPARE(item->y(), i*20.0);
QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
@@ -6789,7 +6749,7 @@ void tst_QQuickListView::populateTransitions()
itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->x(), 0.0);
QTRY_COMPARE(item->y(), i*20.0);
QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
@@ -6831,7 +6791,7 @@ void tst_QQuickListView::sizeTransitions()
QaimModel model;
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("topToBottom", topToBottom);
- TestObject *testObject = new TestObject;
+ QScopedPointer<TestObject> testObject(new TestObject);
ctxt->setContextProperty("testObject", &model);
window->setSource(testFileUrl("sizeTransitions.qml"));
window->show();
@@ -6852,7 +6812,6 @@ void tst_QQuickListView::sizeTransitions()
QCOMPARE(listview->property("transitionFinished").toBool(), true);
releaseView(window);
- delete testObject;
}
void tst_QQuickListView::sizeTransitions_data()
@@ -6889,13 +6848,13 @@ void tst_QQuickListView::addTransitions()
QQuickView *window = getView();
QQmlContext *ctxt = window->rootContext();
- TestObject *testObject = new TestObject;
+ QScopedPointer<TestObject> testObject(new TestObject);
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- ctxt->setContextProperty("testObject", testObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("addTransitions.qml"));
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -6974,12 +6933,12 @@ void tst_QQuickListView::addTransitions()
break;
}
}
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+ QVERIFY2(firstVisibleIndex >= 0, QByteArray::number(firstVisibleIndex));
// verify all items moved to the correct final positions
for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->y(), i*20.0);
QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
QVERIFY(name != nullptr);
@@ -6987,7 +6946,6 @@ void tst_QQuickListView::addTransitions()
}
releaseView(window);
- delete testObject;
}
void tst_QQuickListView::addTransitions_data()
@@ -7085,13 +7043,13 @@ void tst_QQuickListView::moveTransitions()
QQuickView *window = getView();
QQmlContext *ctxt = window->rootContext();
- TestObject *testObject = new TestObject;
+ QScopedPointer<TestObject> testObject(new TestObject);
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia);
ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia);
ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- ctxt->setContextProperty("testObject", testObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("moveTransitions.qml"));
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -7158,13 +7116,13 @@ void tst_QQuickListView::moveTransitions()
break;
}
}
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+ QVERIFY2(firstVisibleIndex >= 0, QByteArray::number(firstVisibleIndex));
// verify all items moved to the correct final positions
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
name = findItem<QQuickText>(contentItem, "textName", i);
QVERIFY(name != nullptr);
@@ -7172,7 +7130,6 @@ void tst_QQuickListView::moveTransitions()
}
releaseView(window);
- delete testObject;
}
void tst_QQuickListView::moveTransitions_data()
@@ -7288,13 +7245,13 @@ void tst_QQuickListView::removeTransitions()
QQuickView *window = getView();
QQmlContext *ctxt = window->rootContext();
- TestObject *testObject = new TestObject;
+ QScopedPointer<TestObject> testObject(new TestObject);
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo);
ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo);
ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- ctxt->setContextProperty("testObject", testObject);
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("removeTransitions.qml"));
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -7372,12 +7329,12 @@ void tst_QQuickListView::removeTransitions()
if (index < 0)
itemCount--; // exclude deleted items
}
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+ QVERIFY2(firstVisibleIndex >= 0, QByteArray::number(firstVisibleIndex));
// verify all items moved to the correct final positions
for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QCOMPARE(item->x(), 0.0);
QCOMPARE(item->y(), contentY + (i-firstVisibleIndex) * 20.0);
QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
@@ -7386,7 +7343,6 @@ void tst_QQuickListView::removeTransitions()
}
releaseView(window);
- delete testObject;
}
void tst_QQuickListView::removeTransitions_data()
@@ -7487,9 +7443,9 @@ void tst_QQuickListView::displacedTransitions()
QQuickView *window = getView();
QQmlContext *ctxt = window->rootContext();
- TestObject *testObject = new TestObject(window);
+ QScopedPointer<TestObject> testObject(new TestObject(window));
ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testObject", testObject);
+ ctxt->setContextProperty("testObject", testObject.data());
ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia);
ctxt->setContextProperty("model_addDisplaced_transitionVia", &model_addDisplaced_transitionVia);
ctxt->setContextProperty("model_moveDisplaced_transitionVia", &model_moveDisplaced_transitionVia);
@@ -7510,7 +7466,6 @@ void tst_QQuickListView::displacedTransitions()
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
-
QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
@@ -7592,7 +7547,7 @@ void tst_QQuickListView::displacedTransitions()
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
for (int i=0; i < model.count() && i < items.count(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QCOMPARE(item->x(), 0.0);
QCOMPARE(item->y(), i * 20.0);
QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
@@ -7714,9 +7669,9 @@ void tst_QQuickListView::multipleTransitions()
QQuickView *window = getView();
QQmlContext *ctxt = window->rootContext();
- TestObject *testObject = new TestObject;
+ QScopedPointer<TestObject> testObject(new TestObject);
ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testObject", testObject);
+ ctxt->setContextProperty("testObject", testObject.data());
ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom);
ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom);
ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom);
@@ -7800,7 +7755,7 @@ void tst_QQuickListView::multipleTransitions()
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
for (int i=0; i < model.count() && i < items.count(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->x(), 0.0);
QTRY_COMPARE(item->y(), i*20.0);
QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
@@ -7809,7 +7764,6 @@ void tst_QQuickListView::multipleTransitions()
}
releaseView(window);
- delete testObject;
}
void tst_QQuickListView::multipleTransitions_data()
@@ -7882,8 +7836,9 @@ void tst_QQuickListView::multipleDisplaced()
QQuickView *window = getView();
QQmlContext *ctxt = window->rootContext();
+ QScopedPointer<TestObject> testObject(new TestObject(window));
ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testObject", new TestObject(window));
+ ctxt->setContextProperty("testObject", testObject.data());
window->setSource(testFileUrl("multipleDisplaced.qml"));
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -7902,14 +7857,14 @@ void tst_QQuickListView::multipleDisplaced()
QVariantMap transitionsStarted = listview->property("displaceTransitionsStarted").toMap();
foreach (const QString &name, transitionsStarted.keys()) {
QVERIFY2(transitionsStarted[name] == 1,
- QTest::toString(QString("%1 was displaced %2 times").arg(name).arg(transitionsStarted[name].toInt())));
+ qPrintable(QString("%1 was displaced %2 times").arg(name).arg(transitionsStarted[name].toInt())));
}
// verify all items moved to the correct final positions
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
for (int i=0; i < model.count() && i < items.count(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->x(), 0.0);
QTRY_COMPARE(item->y(), i*20.0);
QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
@@ -7951,7 +7906,7 @@ void tst_QQuickListView::matchItemsAndIndexes(const QVariantMap &items, const Qa
QCOMPARE(it.value().type(), QVariant::Int);
QString name = it.key();
int itemIndex = it.value().toInt();
- QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
+ QVERIFY2(expectedIndexes.contains(itemIndex), qPrintable(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
if (model.name(itemIndex) != name)
qDebug() << itemIndex;
QCOMPARE(model.name(itemIndex), name);
@@ -7966,8 +7921,8 @@ void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QLi
QVariantList current = itemLists[i].toList();
for (int j=0; j<current.count(); j++) {
QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
- QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
- QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
+ QVERIFY2(o, qPrintable(QString("Invalid actual item at %1").arg(j)));
+ QVERIFY2(expectedItems.contains(o), qPrintable(QString("Cannot match item %1").arg(j)));
}
QCOMPARE(current.count(), expectedItems.count());
}
@@ -8141,7 +8096,7 @@ void tst_QQuickListView::defaultHighlightMoveDuration()
QQmlComponent component(&engine);
component.setData("import QtQuick 2.0; ListView {}", QUrl::fromLocalFile(""));
- QObject *obj = component.create();
+ QScopedPointer<QObject> obj(component.create());
QVERIFY(obj);
QCOMPARE(obj->property("highlightMoveDuration").toInt(), -1);
@@ -8957,15 +8912,15 @@ void tst_QQuickListView::programmaticFlickAtBounds3()
void tst_QQuickListView::layoutChange()
{
- RandomSortModel *model = new RandomSortModel;
- QSortFilterProxyModel *sortModel = new QSortFilterProxyModel;
- sortModel->setSourceModel(model);
+ QScopedPointer<RandomSortModel> model(new RandomSortModel);
+ QScopedPointer<QSortFilterProxyModel> sortModel(new QSortFilterProxyModel);
+ sortModel->setSourceModel(model.data());
sortModel->setSortRole(Qt::UserRole);
sortModel->setDynamicSortFilter(true);
sortModel->sort(0);
QScopedPointer<QQuickView> window(createView());
- window->rootContext()->setContextProperty("testModel", QVariant::fromValue(sortModel));
+ window->rootContext()->setContextProperty("testModel", QVariant::fromValue(sortModel.data()));
window->setSource(testFileUrl("layoutChangeSort.qml"));
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
@@ -9113,7 +9068,8 @@ void tst_QQuickListView::objectModel()
QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("objectmodel.qml"));
- QQuickListView *listview = qobject_cast<QQuickListView *>(component.create());
+ QScopedPointer<QObject> obj(component.create());
+ QQuickListView *listview = qobject_cast<QQuickListView *>(obj.data());
QVERIFY(listview);
QQmlObjectModel *model = listview->model().value<QQmlObjectModel *>();
@@ -9153,8 +9109,6 @@ void tst_QQuickListView::objectModel()
model->clear();
QCOMPARE(model->count(), 0);
QCOMPARE(listview->count(), 0);
-
- delete listview;
}
void tst_QQuickListView::contentHeightWithDelayRemove_data()
@@ -9572,13 +9526,13 @@ void tst_QQuickListView::releaseItems()
void tst_QQuickListView::QTBUG_34576_velocityZero()
{
- QQuickView *window = new QQuickView(nullptr);
+ QScopedPointer<QQuickView> window(new QQuickView(nullptr));
window->setGeometry(0,0,240,320);
QString filename(testFile("qtbug34576.qml"));
window->setSource(QUrl::fromLocalFile(filename));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
QVERIFY(listview);
@@ -9601,8 +9555,8 @@ void tst_QQuickListView::QTBUG_34576_velocityZero()
QSignalSpy currentIndexChangedSpy(listview, SIGNAL(currentIndexChanged()));
// click button which increases currentIndex
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(295,215));
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(295,215));
+ QTest::mousePress(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(295,215));
+ QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(295,215));
// verify that currentIndexChanged is triggered
QTRY_VERIFY(currentIndexChangedSpy.count() > 0);
@@ -9613,8 +9567,6 @@ void tst_QQuickListView::QTBUG_34576_velocityZero()
// velocity should be always > 0.0
QTRY_COMPARE(window->rootObject()->property("horizontalVelocityZeroCount").toInt(), 0);
-
- delete window;
}
void tst_QQuickListView::QTBUG_61537_modelChangesAsync()
diff --git a/tests/auto/quick/qquickrendercontrol/data/rect.qml b/tests/auto/quick/qquickrendercontrol/data/rect.qml
new file mode 100644
index 0000000000..5f58869fb5
--- /dev/null
+++ b/tests/auto/quick/qquickrendercontrol/data/rect.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Rectangle {
+ width: 200
+ height: 200
+ color: "steelblue"
+ Rectangle {
+ id: r
+ width: 150
+ height: 150
+ anchors.centerIn: parent
+ color: "palegreen"
+ NumberAnimation on rotation { from: 0; to: 360; duration: 5000; loops: -1 }
+ }
+ Text {
+ text: "Hello World\n\nrotation=" + Math.round(r.rotation)
+ anchors.centerIn: parent
+ }
+}
diff --git a/tests/auto/quick/qquickrendercontrol/qquickrendercontrol.pro b/tests/auto/quick/qquickrendercontrol/qquickrendercontrol.pro
new file mode 100644
index 0000000000..958abe316d
--- /dev/null
+++ b/tests/auto/quick/qquickrendercontrol/qquickrendercontrol.pro
@@ -0,0 +1,12 @@
+CONFIG += testcase
+TARGET = tst_qquickrendercontrol
+SOURCES += tst_qquickrendercontrol.cpp
+
+include (../../shared/util.pri)
+
+macos:CONFIG -= app_bundle
+
+QT += core-private gui-private qml-private quick-private testlib opengl
+
+OTHER_FILES += \
+ data/rect.qml
diff --git a/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp b/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp
new file mode 100644
index 0000000000..4bab4e345a
--- /dev/null
+++ b/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp
@@ -0,0 +1,202 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+
+#if QT_CONFIG(opengl)
+#include <QOffscreenSurface>
+#include <QOpenGLContext>
+#include <QOpenGLFunctions>
+#include <QOpenGLFramebufferObject>
+#endif
+#include <QAnimationDriver>
+
+#include <QQuickWindow>
+#include <QQuickRenderControl>
+#include <QQuickItem>
+#include <QQmlEngine>
+#include <QQmlComponent>
+
+#include "../../shared/util.h"
+
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformintegration.h>
+
+class tst_RenderControl : public QQmlDataTest
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void renderAndReadBack();
+};
+
+void tst_RenderControl::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+}
+
+class AnimationDriver : public QAnimationDriver
+{
+public:
+ AnimationDriver(int msPerStep) : m_step(msPerStep) { }
+
+ void advance() override
+ {
+ m_elapsed += m_step;
+ advanceAnimation();
+ }
+
+ qint64 elapsed() const override
+ {
+ return m_elapsed;
+ }
+
+private:
+ int m_step;
+ qint64 m_elapsed = 0;
+};
+
+
+void tst_RenderControl::renderAndReadBack()
+{
+ static const int ANIM_ADVANCE_PER_FRAME = 16; // milliseconds
+ QScopedPointer<AnimationDriver> animDriver(new AnimationDriver(ANIM_ADVANCE_PER_FRAME));
+ animDriver->install();
+
+ // ### Qt 6: migrate this to OpenGL-on-RHI
+#if QT_CONFIG(opengl)
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
+ QSKIP("Skipping due to platform not supporting OpenGL at run time");
+
+ QScopedPointer<QOpenGLContext> context(new QOpenGLContext);
+ QVERIFY(context->create());
+ QScopedPointer<QOffscreenSurface> offscreenSurface(new QOffscreenSurface);
+ offscreenSurface->setFormat(context->format());
+ offscreenSurface->create();
+ QVERIFY(context->makeCurrent(offscreenSurface.data()));
+
+ QScopedPointer<QQuickRenderControl> renderControl(new QQuickRenderControl);
+ QScopedPointer<QQuickWindow> quickWindow(new QQuickWindow(renderControl.data()));
+ QScopedPointer<QQmlEngine> qmlEngine(new QQmlEngine);
+
+ QScopedPointer<QQmlComponent> qmlComponent(new QQmlComponent(qmlEngine.data(), testFileUrl(QLatin1String("rect.qml"))));
+ QVERIFY(!qmlComponent->isLoading());
+ if (qmlComponent->isError()) {
+ for (const QQmlError &error : qmlComponent->errors())
+ qWarning() << error.url() << error.line() << error;
+ }
+ QVERIFY(!qmlComponent->isError());
+
+ QObject *rootObject = qmlComponent->create();
+ if (qmlComponent->isError()) {
+ for (const QQmlError &error : qmlComponent->errors())
+ qWarning() << error.url() << error.line() << error;
+ }
+ QVERIFY(!qmlComponent->isError());
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem *>(rootObject);
+ QVERIFY(rootItem);
+ QCOMPARE(rootItem->size(), QSize(200, 200));
+
+ quickWindow->contentItem()->setSize(rootItem->size());
+ quickWindow->setGeometry(0, 0, rootItem->width(), rootItem->height());
+
+ rootItem->setParentItem(quickWindow->contentItem());
+
+ renderControl->initialize(context.data());
+
+ // cannot do this test with the 'software' backend of Qt Quick
+ QSGRendererInterface::GraphicsApi api = quickWindow->rendererInterface()->graphicsApi();
+ if (api != QSGRendererInterface::OpenGL)
+ QSKIP("Skipping due to Qt Quick not using the direct OpenGL rendering path");
+
+ QScopedPointer<QOpenGLFramebufferObject> fbo(new QOpenGLFramebufferObject(rootItem->size().toSize(),
+ QOpenGLFramebufferObject::CombinedDepthStencil));
+
+ quickWindow->setRenderTarget(fbo.data());
+
+ for (int frame = 0; frame < 100; ++frame) {
+ // have to process events, e.g. to get queued metacalls delivered
+ QCoreApplication::processEvents();
+
+ if (frame > 0) {
+ // Quick animations will now think that ANIM_ADVANCE_PER_FRAME milliseconds have passed,
+ // even though in reality we have a tight loop that generates frames unthrottled.
+ animDriver->advance();
+ }
+
+ renderControl->polishItems();
+ renderControl->sync();
+ renderControl->render();
+
+ context->functions()->glFlush();
+
+ QImage img = fbo->toImage();
+ QVERIFY(!img.isNull());
+ QCOMPARE(img.size(), rootItem->size());
+
+ const int maxFuzz = 2;
+
+ // The scene is: background, rectangle, text
+ // where rectangle rotates
+
+ QRgb background = img.pixel(5, 5);
+ QVERIFY(qAbs(qRed(background) - 70) < maxFuzz);
+ QVERIFY(qAbs(qGreen(background) - 130) < maxFuzz);
+ QVERIFY(qAbs(qBlue(background) - 180) < maxFuzz);
+
+ background = img.pixel(195, 195);
+ QVERIFY(qAbs(qRed(background) - 70) < maxFuzz);
+ QVERIFY(qAbs(qGreen(background) - 130) < maxFuzz);
+ QVERIFY(qAbs(qBlue(background) - 180) < maxFuzz);
+
+ // after about 1.25 seconds (animation time, one iteration is 16 ms
+ // thanks to our custom animation driver) the rectangle reaches a 90
+ // degree rotation, that should be frame 76
+ if (frame <= 2 || (frame >= 76 && frame <= 80)) {
+ QRgb c = img.pixel(28, 28); // rectangle
+ QVERIFY(qAbs(qRed(c) - 152) < maxFuzz);
+ QVERIFY(qAbs(qGreen(c) - 251) < maxFuzz);
+ QVERIFY(qAbs(qBlue(c) - 152) < maxFuzz);
+ } else {
+ QRgb c = img.pixel(28, 28); // background because rectangle got rotated so this pixel is not covered by it
+ QVERIFY(qAbs(qRed(c) - 70) < maxFuzz);
+ QVERIFY(qAbs(qGreen(c) - 130) < maxFuzz);
+ QVERIFY(qAbs(qBlue(c) - 180) < maxFuzz);
+ }
+ }
+
+#else
+ QSKIP("No OpenGL, skipping rendercontrol test");
+#endif
+}
+
+#include "tst_qquickrendercontrol.moc"
+
+QTEST_MAIN(tst_RenderControl)
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index 71b5794e81..273f31bad1 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -15,7 +15,8 @@ qtConfig(opengl(es1|es2)?) {
qquickframebufferobject \
qquickopenglinfo \
qquickspritesequence \
- qquickshadereffect
+ qquickshadereffect \
+ qquickrendercontrol
}
!cross_compile: PRIVATETESTS += examples
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp
index 4089e5ddae..67b73f047c 100644
--- a/tests/auto/quick/shared/viewtestutil.cpp
+++ b/tests/auto/quick/shared/viewtestutil.cpp
@@ -282,14 +282,28 @@ void QQuickViewTestUtil::QaimModel::resetItems(const QList<QPair<QString, QStrin
endResetModel();
}
+class ScopedPrintable
+{
+ Q_DISABLE_COPY_MOVE(ScopedPrintable)
+
+public:
+ ScopedPrintable(const QString &string) : data(QTest::toString(string)) {}
+ ~ScopedPrintable() { delete[] data; }
+
+ operator const char*() const { return data; }
+
+private:
+ const char *data;
+};
+
void QQuickViewTestUtil::QaimModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) {
for (int i=0; i<other.count(); i++) {
QVERIFY2(list.contains(other[i]),
- QTest::toString(other[i].first + QLatin1Char(' ') + other[i].second + QLatin1Char(' ') + error1));
+ ScopedPrintable(other[i].first + QLatin1Char(' ') + other[i].second + QLatin1Char(' ') + error1));
}
for (int i=0; i<list.count(); i++) {
QVERIFY2(other.contains(list[i]),
- QTest::toString(list[i].first + QLatin1Char(' ') + list[i].second + QLatin1Char(' ') + error2));
+ ScopedPrintable(list[i].first + QLatin1Char(' ') + list[i].second + QLatin1Char(' ') + error2));
}
}