diff options
26 files changed, 198 insertions, 146 deletions
diff --git a/src/3rdparty/masm/yarr/YarrJIT.cpp b/src/3rdparty/masm/yarr/YarrJIT.cpp index 73c919dd90..98e4ade51f 100644 --- a/src/3rdparty/masm/yarr/YarrJIT.cpp +++ b/src/3rdparty/masm/yarr/YarrJIT.cpp @@ -642,7 +642,7 @@ class YarrGenerator : private DefaultMacroAssembler { subPtr(Imm32(callFrameSizeInBytes), stackPointerRegister); if (callFrameSizeInBytes <= 128) { for (unsigned offset = 0; offset < callFrameSizeInBytes; offset += sizeof(intptr_t)) - storePtr(TrustedImmPtr(0), Address(regT0, -8 - offset)); + storePtr(TrustedImmPtr(0), Address(regT0, -8 - int(offset))); } else { Label zeroLoop = label(); subPtr(TrustedImm32(sizeof(intptr_t) * 2), regT0); diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index b8497937c1..e68a563a45 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -201,8 +201,8 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) // first locals const quint32_le *localsIndices = compiledBlock->localsTable(); - for (quint32 i = 0; i < compiledBlock->nLocals; ++i) - ic = ic->addMember(engine->identifierTable->asPropertyKey(runtimeStrings[localsIndices[i]]), Attr_NotConfigurable); + for (quint32 j = 0; j < compiledBlock->nLocals; ++j) + ic = ic->addMember(engine->identifierTable->asPropertyKey(runtimeStrings[localsIndices[j]]), Attr_NotConfigurable); runtimeBlocks[i] = ic->d(); } diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 0c5436a0d6..936c032fad 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -739,7 +739,7 @@ QString Stringify::Str(const QString &key, const Value &v) } if (const QV4::VariantObject *v = value->as<QV4::VariantObject>()) { - return v->d()->data().toString(); + return quote(v->d()->data().toString()); } o = value->asReturnedValue(); diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index cbf5a6e259..3710cee162 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -640,7 +640,8 @@ void QQmlContextData::destroy() QQmlData *co = contextObjects; contextObjects = contextObjects->nextContextObject; - co->context = nullptr; + if (co->context == this) + co->context = nullptr; co->outerContext = nullptr; co->nextContextObject = nullptr; co->prevContextObject = nullptr; @@ -783,13 +784,17 @@ void QQmlContextData::refreshExpressions() } } -void QQmlContextData::addObject(QObject *o) +void QQmlContextData::addObject(QQmlData *data) { - QQmlData *data = QQmlData::get(o, true); - - Q_ASSERT(data->context == nullptr); + if (data->outerContext) { + if (data->nextContextObject) + data->nextContextObject->prevContextObject = data->prevContextObject; + if (data->prevContextObject) + *data->prevContextObject = data->nextContextObject; + else if (data->outerContext->contextObjects == data) + data->outerContext->contextObjects = data->nextContextObject; + } - data->context = this; data->outerContext = this; data->nextContextObject = contextObjects; diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h index 290b7fc7ee..7e3cef8e1d 100644 --- a/src/qml/qml/qqmlcontext_p.h +++ b/src/qml/qml/qqmlcontext_p.h @@ -129,7 +129,7 @@ public: void setParent(QQmlContextData *, bool stronglyReferencedByParent = false); void refreshExpressions(); - void addObject(QObject *); + void addObject(QQmlData *data); QUrl resolvedUrl(const QUrl &); diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index c400e9239b..6db43a50eb 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1518,7 +1518,9 @@ void QQmlEngine::setContextForObject(QObject *object, QQmlContext *context) } QQmlContextData *contextData = QQmlContextData::get(context); - contextData->addObject(object); + Q_ASSERT(data->context == nullptr); + data->context = contextData; + contextData->addObject(data); } /*! @@ -1882,6 +1884,8 @@ void QQmlData::destroyed(QObject *object) nextContextObject->prevContextObject = prevContextObject; if (prevContextObject) *prevContextObject = nextContextObject; + else if (outerContext && outerContext->contextObjects == this) + outerContext->contextObjects = nextContextObject; QQmlAbstractBinding *binding = bindings; while (binding) { diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index c181d791f5..68e2c2c928 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -1230,13 +1230,15 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo QQmlContextData *c = ddata->context; while (c->linkedContext) c = c->linkedContext; c->linkedContext = context; - } else - context->addObject(instance); + } else { + ddata->context = context; + } ddata->ownContext = ddata->context; - } else if (!ddata->context) - context->addObject(instance); + } else if (!ddata->context) { + ddata->context = context; + } - ddata->outerContext = context; + context->addObject(ddata); if (parserStatus) { parserStatus->classBegin(); diff --git a/src/quick/handlers/qquickmultipointhandler.cpp b/src/quick/handlers/qquickmultipointhandler.cpp index 2f4e9d45e9..228c99bb12 100644 --- a/src/quick/handlers/qquickmultipointhandler.cpp +++ b/src/quick/handlers/qquickmultipointhandler.cpp @@ -309,6 +309,8 @@ void QQuickMultiPointHandler::acceptPoints(const QVector<QQuickEventPoint *> &po bool QQuickMultiPointHandler::grabPoints(QVector<QQuickEventPoint *> points) { + if (points.isEmpty()) + return false; bool allowed = true; for (QQuickEventPoint* point : points) { if (point->exclusiveGrabber() != this && !canGrab(point)) { diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 908801ce1c..62cbfcef2b 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -2456,7 +2456,18 @@ QString QQuickListView::currentSection() const The default value for the duration properties is -1, i.e. the highlight will take as much time as necessary to move at the set speed. - These properties have the same characteristics as a SmoothedAnimation. + These properties have the same characteristics as a SmoothedAnimation: + if both the velocity and duration are set, the animation will use + whichever gives the shorter duration. + + To set only one property, the other can be set to \c -1. For example, + if you only want to animate the duration and not velocity, use the + following code: + + \code + highlightMoveDuration: 1000 + highlightMoveVelocity: -1 + \endcode \sa highlightFollowsCurrentItem */ diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index ea6d376ce7..ced0acd9ab 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -480,6 +480,10 @@ QQuickPixmapReader::QQuickPixmapReader(QQmlEngine *eng) eventLoopQuitHack->moveToThread(this); connect(eventLoopQuitHack, SIGNAL(destroyed(QObject*)), SLOT(quit()), Qt::DirectConnection); start(QThread::LowestPriority); +#if !QT_CONFIG(thread) + // call nonblocking run ourself, as nothread qthread does not + run(); +#endif } QQuickPixmapReader::~QQuickPixmapReader() @@ -957,8 +961,11 @@ void QQuickPixmapReader::run() processJobs(); exec(); +#if QT_CONFIG(thread) + // nothread exec is empty and returns delete threadObject; threadObject = nullptr; +#endif } class QQuickPixmapKey @@ -1028,7 +1035,8 @@ QQuickPixmapStore::~QQuickPixmapStore() m_timerId = -2; // unreference all (leaked) pixmaps - for (auto *pixmap : qAsConst(m_cache)) { + const auto cache = m_cache; // NOTE: intentional copy (QTBUG-65077); releasing items from the cache modifies m_cache. + for (auto *pixmap : cache) { int currRefCount = pixmap->refCount; if (currRefCount) { #ifndef QT_NO_DEBUG diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/BLACKLIST b/tests/auto/qml/animation/qsequentialanimationgroupjob/BLACKLIST deleted file mode 100644 index 2afe6074d7..0000000000 --- a/tests/auto/qml/animation/qsequentialanimationgroupjob/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[finishWithUncontrolledAnimation] -* diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index efd5bb571b..7c7c7d3bd0 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -173,8 +173,8 @@ void tst_qqmlcomponent::qmlCreateWindow() QQmlEngine engine; QQmlComponent component(&engine); component.loadUrl(testFileUrl("createWindow.qml")); - QQuickWindow* window = qobject_cast<QQuickWindow *>(component.create()); - QVERIFY(window); + QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(component.create())); + QVERIFY(!window.isNull()); } void tst_qqmlcomponent::qmlCreateObjectAutoParent_data() @@ -192,8 +192,8 @@ void tst_qqmlcomponent::qmlCreateObjectAutoParent() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl(testFile)); - QQuickItem *root = qobject_cast<QQuickItem *>(component.create()); - QVERIFY(root); + QScopedPointer<QObject> root(qobject_cast<QQuickItem *>(component.create())); + QVERIFY(!root.isNull()); QObject *qtobjectParent = root->property("qtobjectParent").value<QObject*>(); QQuickItem *itemParent = qobject_cast<QQuickItem *>(root->property("itemParent").value<QObject*>()); QQuickWindow *windowParent = qobject_cast<QQuickWindow *>(root->property("windowParent").value<QObject*>()); @@ -251,45 +251,52 @@ void tst_qqmlcomponent::qmlCreateObjectWithProperties() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("createObjectWithScript.qml")); QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8()); - QObject *object = component.create(); - QVERIFY(object != nullptr); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); - QObject *testObject1 = object->property("declarativerectangle").value<QObject*>(); - QVERIFY(testObject1); - QCOMPARE(testObject1->parent(), object); - QCOMPARE(testObject1->property("x").value<int>(), 17); - QCOMPARE(testObject1->property("y").value<int>(), 17); - QCOMPARE(testObject1->property("color").value<QColor>(), QColor(255,255,255)); - QCOMPARE(QQmlProperty::read(testObject1,"border.width").toInt(), 3); - QCOMPARE(QQmlProperty::read(testObject1,"innerRect.border.width").toInt(), 20); - delete testObject1; - - QObject *testObject2 = object->property("declarativeitem").value<QObject*>(); - QVERIFY(testObject2); - QCOMPARE(testObject2->parent(), object); - //QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem_QML_2"); - QCOMPARE(testObject2->property("x").value<int>(), 17); - QCOMPARE(testObject2->property("y").value<int>(), 17); - QCOMPARE(testObject2->property("testBool").value<bool>(), true); - QCOMPARE(testObject2->property("testInt").value<int>(), 17); - QCOMPARE(testObject2->property("testObject").value<QObject*>(), object); - delete testObject2; - - QObject *testBindingObj = object->property("bindingTestObject").value<QObject*>(); - QVERIFY(testBindingObj); - QCOMPARE(testBindingObj->parent(), object); - QCOMPARE(testBindingObj->property("testValue").value<int>(), 300); - object->setProperty("width", 150); - QCOMPARE(testBindingObj->property("testValue").value<int>(), 150 * 3); - delete testBindingObj; - - QObject *testBindingThisObj = object->property("bindingThisTestObject").value<QObject*>(); - QVERIFY(testBindingThisObj); - QCOMPARE(testBindingThisObj->parent(), object); - QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 900); - testBindingThisObj->setProperty("width", 200); - QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 200 * 3); - delete testBindingThisObj; + { + QScopedPointer<QObject> testObject1(object->property("declarativerectangle") + .value<QObject*>()); + QVERIFY(testObject1); + QCOMPARE(testObject1->parent(), object.data()); + QCOMPARE(testObject1->property("x").value<int>(), 17); + QCOMPARE(testObject1->property("y").value<int>(), 17); + QCOMPARE(testObject1->property("color").value<QColor>(), QColor(255,255,255)); + QCOMPARE(QQmlProperty::read(testObject1.data(),"border.width").toInt(), 3); + QCOMPARE(QQmlProperty::read(testObject1.data(),"innerRect.border.width").toInt(), 20); + } + + { + QScopedPointer<QObject> testObject2(object->property("declarativeitem").value<QObject*>()); + QVERIFY(testObject2); + QCOMPARE(testObject2->parent(), object.data()); + //QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem_QML_2"); + QCOMPARE(testObject2->property("x").value<int>(), 17); + QCOMPARE(testObject2->property("y").value<int>(), 17); + QCOMPARE(testObject2->property("testBool").value<bool>(), true); + QCOMPARE(testObject2->property("testInt").value<int>(), 17); + QCOMPARE(testObject2->property("testObject").value<QObject*>(), object.data()); + } + + { + QScopedPointer<QObject> testBindingObj(object->property("bindingTestObject") + .value<QObject*>()); + QVERIFY(testBindingObj); + QCOMPARE(testBindingObj->parent(), object.data()); + QCOMPARE(testBindingObj->property("testValue").value<int>(), 300); + object->setProperty("width", 150); + QCOMPARE(testBindingObj->property("testValue").value<int>(), 150 * 3); + } + + { + QScopedPointer<QObject> testBindingThisObj(object->property("bindingThisTestObject") + .value<QObject*>()); + QVERIFY(testBindingThisObj); + QCOMPARE(testBindingThisObj->parent(), object.data()); + QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 900); + testBindingThisObj->setProperty("width", 200); + QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 200 * 3); + } } void tst_qqmlcomponent::qmlCreateParentReference() diff --git a/tests/auto/qml/qqmlcontext/data/Drawer.qml b/tests/auto/qml/qqmlcontext/data/Drawer.qml new file mode 100644 index 0000000000..b35d5c8d34 --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/Drawer.qml @@ -0,0 +1,6 @@ +import QtQuick 2.12 +import QtQuick.Window 2.11 + +Rectangle { + parent: Window.contentItem +} diff --git a/tests/auto/qml/qqmlcontext/data/contextObjectHierarchy.qml b/tests/auto/qml/qqmlcontext/data/contextObjectHierarchy.qml new file mode 100644 index 0000000000..91978d98a0 --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/contextObjectHierarchy.qml @@ -0,0 +1,6 @@ +import QtQuick 2.6 +import QtQuick.Window 2.2 + +Window { + Drawer {} +} diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp index 5838193a6b..89640bc385 100644 --- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp +++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp @@ -70,6 +70,7 @@ private slots: void contextLeak(); void outerContextObject(); + void contextObjectHierarchy(); private: QQmlEngine engine; @@ -873,6 +874,24 @@ void tst_qqmlcontext::outerContextObject() QTRY_VERIFY(iterations >= 100); } +void tst_qqmlcontext::contextObjectHierarchy() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("contextObjectHierarchy.qml")); + QVERIFY(component.isReady()); + QScopedPointer<QObject> root(component.create()); + QVERIFY(!root.isNull()); + + for (const QObject *child : root->children()) { + QQmlData *d = QQmlData::get(child); + QVERIFY(d->outerContext != nullptr); + connect(root.data(), &QObject::destroyed, [&]() { + QCOMPARE(d->outerContext, nullptr); + }); + } +} + QTEST_MAIN(tst_qqmlcontext) #include "tst_qqmlcontext.moc" diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 254a6bc878..085cd5ffd0 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -8464,7 +8464,8 @@ void tst_qqmlecmascript::stringify_qtbug_50592() QScopedPointer<QObject> obj(component.create()); QVERIFY(obj != nullptr); - QCOMPARE(obj->property("source").toString(), QString::fromLatin1("http://example.org/some_nonexistant_image.png")); + QCOMPARE(obj->property("source").toString(), + QString::fromLatin1("\"http://example.org/some_nonexistant_image.png\"")); } // Tests for the JS-only instanceof. Tests for the QML extensions for diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp index 02e89ba0a7..9292e1886a 100644 --- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp +++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp @@ -596,7 +596,9 @@ void tst_qquickborderimage::borderImageMesh() window->setSource(testFileUrl("mesh.qml")); QImage mesh = window->grabWindow(); - QVERIFY(QQuickVisualTestUtil::compareImages(mesh, nonmesh)); + QString errorMessage; + QVERIFY2(QQuickVisualTestUtil::compareImages(mesh, nonmesh, &errorMessage), + qPrintable(errorMessage)); } #endif QTEST_MAIN(tst_qquickborderimage) diff --git a/tests/auto/quick/qquickshape/tst_qquickshape.cpp b/tests/auto/quick/qquickshape/tst_qquickshape.cpp index 3206129e72..61fb260612 100644 --- a/tests/auto/quick/qquickshape/tst_qquickshape.cpp +++ b/tests/auto/quick/qquickshape/tst_qquickshape.cpp @@ -233,7 +233,10 @@ void tst_QQuickShape::render() QImage refImg(testFileUrl("pathitem3.png").toLocalFile()); QVERIFY(!refImg.isNull()); - QVERIFY(QQuickVisualTestUtil::compareImages(img.convertToFormat(refImg.format()), refImg)); + QString errorMessage; + const QImage actualImg = img.convertToFormat(refImg.format()); + QVERIFY2(QQuickVisualTestUtil::compareImages(actualImg, refImg, &errorMessage), + qPrintable(errorMessage)); } void tst_QQuickShape::renderWithMultipleSp() @@ -254,7 +257,10 @@ void tst_QQuickShape::renderWithMultipleSp() QImage refImg(testFileUrl("pathitem4.png").toLocalFile()); QVERIFY(!refImg.isNull()); - QVERIFY(QQuickVisualTestUtil::compareImages(img.convertToFormat(refImg.format()), refImg)); + QString errorMessage; + const QImage actualImg = img.convertToFormat(refImg.format()); + QVERIFY2(QQuickVisualTestUtil::compareImages(actualImg, refImg, &errorMessage), + qPrintable(errorMessage)); } void tst_QQuickShape::radialGrad() @@ -275,7 +281,10 @@ void tst_QQuickShape::radialGrad() QImage refImg(testFileUrl("pathitem5.png").toLocalFile()); QVERIFY(!refImg.isNull()); - QVERIFY(QQuickVisualTestUtil::compareImages(img.convertToFormat(refImg.format()), refImg)); + QString errorMessage; + const QImage actualImg = img.convertToFormat(refImg.format()); + QVERIFY2(QQuickVisualTestUtil::compareImages(actualImg, refImg, &errorMessage), + qPrintable(errorMessage)); } void tst_QQuickShape::conicalGrad() @@ -296,7 +305,10 @@ void tst_QQuickShape::conicalGrad() QImage refImg(testFileUrl("pathitem6.png").toLocalFile()); QVERIFY(!refImg.isNull()); - QVERIFY(QQuickVisualTestUtil::compareImages(img.convertToFormat(refImg.format()), refImg)); + QString errorMessage; + const QImage actualImg = img.convertToFormat(refImg.format()); + QVERIFY2(QQuickVisualTestUtil::compareImages(actualImg, refImg, &errorMessage), + qPrintable(errorMessage)); } QTEST_MAIN(tst_QQuickShape) diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 578ae56cca..ab101dc1be 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1506,44 +1506,6 @@ void tst_qquickwindow::animationsWhileHidden() QTRY_VERIFY(window->isVisible()); } -// When running on native Nvidia graphics cards on linux, the -// distance field glyph pixels have a measurable, but not visible -// pixel error. Use a custom compare function to avoid -// -// This was GT-216 with the ubuntu "nvidia-319" driver package. -// llvmpipe does not show the same issue. -// -bool compareImages(const QImage &ia, const QImage &ib) -{ - if (ia.size() != ib.size()) - qDebug() << "images are of different size" << ia.size() << ib.size(); - Q_ASSERT(ia.size() == ib.size()); - Q_ASSERT(ia.format() == ib.format()); - - int w = ia.width(); - int h = ia.height(); - const int tolerance = 5; - for (int y=0; y<h; ++y) { - const uint *as= (const uint *) ia.constScanLine(y); - const uint *bs= (const uint *) ib.constScanLine(y); - for (int x=0; x<w; ++x) { - uint a = as[x]; - uint b = bs[x]; - - // No tolerance for error in the alpha. - if ((a & 0xff000000) != (b & 0xff000000)) - return false; - if (qAbs(qRed(a) - qRed(b)) > tolerance) - return false; - if (qAbs(qRed(a) - qRed(b)) > tolerance) - return false; - if (qAbs(qRed(a) - qRed(b)) > tolerance) - return false; - } - } - return true; -} - void tst_qquickwindow::headless() { QQmlEngine engine; @@ -1597,7 +1559,9 @@ void tst_qquickwindow::headless() // Verify that the visual output is the same QImage newContent = window->grabWindow(); - QVERIFY(compareImages(newContent, originalContent)); + QString errorMessage; + QVERIFY2(QQuickVisualTestUtil::compareImages(newContent, originalContent, &errorMessage), + qPrintable(errorMessage)); } void tst_qquickwindow::noUpdateWhenNothingChanges() diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index 2479450287..063358c795 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -264,6 +264,7 @@ void tst_SceneGraph::manyWindows() const int COUNT = 4; QImage baseLine; + QString errorMessage; for (int i=0; i<COUNT; ++i) { views << createView(file, parent.data(), (i % 2) * 100, (i / 2) * 100, 100, 100); } @@ -275,7 +276,8 @@ void tst_SceneGraph::manyWindows() baseLine = content; QVERIFY(containsSomethingOtherThanWhite(baseLine)); } else { - QVERIFY(compareImages(content, baseLine)); + QVERIFY2(compareImages(content, baseLine, &errorMessage), + qPrintable(errorMessage)); } } @@ -284,7 +286,8 @@ void tst_SceneGraph::manyWindows() QQuickView *last = createView(file, parent.data(), 100, 100, 100, 100); QVERIFY(QTest::qWaitForWindowExposed(last)); views << last; - QVERIFY(compareImages(baseLine, last->grabWindow())); + QVERIFY2(compareImages(baseLine, last->grabWindow(), &errorMessage), + qPrintable(errorMessage)); // Wipe and recreate all qDeleteAll(views); @@ -297,7 +300,8 @@ void tst_SceneGraph::manyWindows() QQuickView *view = views.at(i); QVERIFY(QTest::qWaitForWindowExposed(view)); QImage content = view->grabWindow(); - QVERIFY(compareImages(content, baseLine)); + QVERIFY2(compareImages(content, baseLine, &errorMessage), + qPrintable(errorMessage)); } } diff --git a/tests/auto/quick/shared/visualtestutil.cpp b/tests/auto/quick/shared/visualtestutil.cpp index eabfe5368b..de2cf2bd5b 100644 --- a/tests/auto/quick/shared/visualtestutil.cpp +++ b/tests/auto/quick/shared/visualtestutil.cpp @@ -66,12 +66,18 @@ void QQuickVisualTestUtil::dumpTree(QQuickItem *parent, int depth) // distance field glyph pixels have a measurable, but not visible // pixel error. This was GT-216 with the ubuntu "nvidia-319" driver package. // llvmpipe does not show the same issue. -bool QQuickVisualTestUtil::compareImages(const QImage &ia, const QImage &ib) + +bool QQuickVisualTestUtil::compareImages(const QImage &ia, const QImage &ib, QString *errorMessage) { - if (ia.size() != ib.size()) - qDebug() << "images are of different size" << ia.size() << ib.size(); - Q_ASSERT(ia.size() == ib.size()); - Q_ASSERT(ia.format() == ib.format()); + if (ia.size() != ib.size()) { + QDebug(errorMessage) << "Images are of different size:" << ia.size() << ib.size() + << "DPR:" << ia.devicePixelRatio() << ib.devicePixelRatio(); + return false; + } + if (ia.format() != ib.format()) { + QDebug(errorMessage) << "Images are of different formats:" << ia.format() << ib.format(); + return false; + } int w = ia.width(); int h = ia.height(); @@ -84,14 +90,14 @@ bool QQuickVisualTestUtil::compareImages(const QImage &ia, const QImage &ib) uint b = bs[x]; // No tolerance for error in the alpha. - if ((a & 0xff000000) != (b & 0xff000000)) - return false; - if (qAbs(qRed(a) - qRed(b)) > tolerance) - return false; - if (qAbs(qRed(a) - qRed(b)) > tolerance) - return false; - if (qAbs(qRed(a) - qRed(b)) > tolerance) + if ((a & 0xff000000) != (b & 0xff000000) + || qAbs(qRed(a) - qRed(b)) > tolerance + || qAbs(qRed(a) - qRed(b)) > tolerance + || qAbs(qRed(a) - qRed(b)) > tolerance) { + QDebug(errorMessage) << "Mismatch at:" << x << y << ':' + << hex << showbase << a << b; return false; + } } } return true; diff --git a/tests/auto/quick/shared/visualtestutil.h b/tests/auto/quick/shared/visualtestutil.h index 74f9dc8cc1..e623e3e225 100644 --- a/tests/auto/quick/shared/visualtestutil.h +++ b/tests/auto/quick/shared/visualtestutil.h @@ -97,7 +97,7 @@ namespace QQuickVisualTestUtil return items; } - bool compareImages(const QImage &ia, const QImage &ib); + bool compareImages(const QImage &ia, const QImage &ib, QString *errorMessage); } #endif // QQUICKVISUALTESTUTIL_H diff --git a/tests/auto/quick/touchmouse/BLACKLIST b/tests/auto/quick/touchmouse/BLACKLIST index e0d4bff131..b2ba52eca9 100644 --- a/tests/auto/quick/touchmouse/BLACKLIST +++ b/tests/auto/quick/touchmouse/BLACKLIST @@ -1,5 +1,2 @@ -# QTBUG-40856 hover regression on pointerhandler branch: TODO fix before merging to dev -[hoverEnabled] -* [buttonOnDelayedPressFlickable] windows gcc developer-build diff --git a/tests/auto/quickwidgets/qquickwidget/BLACKLIST b/tests/auto/quickwidgets/qquickwidget/BLACKLIST deleted file mode 100644 index 6594a22472..0000000000 --- a/tests/auto/quickwidgets/qquickwidget/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[enterLeave] -osx diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index 24e55e3b3a..42dc766a13 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -160,7 +160,7 @@ void tst_qquickwidget::showHide() childView->setSource(testFileUrl("rectangle.qml")); window.show(); - QVERIFY(QTest::qWaitForWindowExposed(&window, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(childView->quickWindow()->isVisible()); QVERIFY(childView->quickWindow()->visibility() != QWindow::Hidden); @@ -176,13 +176,13 @@ void tst_qquickwidget::reparentAfterShow() QQuickWidget *childView = new QQuickWidget(&window); childView->setSource(testFileUrl("rectangle.qml")); window.show(); - QVERIFY(QTest::qWaitForWindowExposed(&window, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window)); QScopedPointer<QQuickWidget> toplevelView(new QQuickWidget); toplevelView->setParent(&window); toplevelView->setSource(testFileUrl("rectangle.qml")); toplevelView->show(); - QVERIFY(QTest::qWaitForWindowExposed(&window, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window)); } void tst_qquickwidget::changeGeometry() @@ -193,7 +193,7 @@ void tst_qquickwidget::changeGeometry() childView->setSource(testFileUrl("rectangle.qml")); window.show(); - QVERIFY(QTest::qWaitForWindowExposed(&window, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window)); childView->setGeometry(100,100,100,100); } @@ -373,7 +373,7 @@ void tst_qquickwidget::readback() view->setSource(testFileUrl("rectangle.qml")); view->show(); - QVERIFY(QTest::qWaitForWindowExposed(view.data(), 5000)); + QVERIFY(QTest::qWaitForWindowExposed(view.data())); QImage img = view->grabFramebuffer(); QVERIFY(!img.isNull()); @@ -409,7 +409,7 @@ void tst_qquickwidget::renderingSignals() QCOMPARE(afterRenderingSpy.size(), 0); widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(&widget, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); QTRY_VERIFY(beforeRenderingSpy.size() > 0); QTRY_VERIFY(beforeSyncSpy.size() > 0); @@ -441,9 +441,9 @@ void tst_qquickwidget::reparentToNewWindow() QQuickWidget *qqw = new QQuickWidget(&window1); qqw->setSource(testFileUrl("rectangle.qml")); window1.show(); - QVERIFY(QTest::qWaitForWindowExposed(&window1, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window1)); window2.show(); - QVERIFY(QTest::qWaitForWindowExposed(&window2, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&window2)); QSignalSpy afterRenderingSpy(qqw->quickWindow(), &QQuickWindow::afterRendering); qqw->setParent(&window2); @@ -488,7 +488,7 @@ void tst_qquickwidget::keyEvents() KeyHandlingWidget widget; widget.setSource(testFileUrl("rectangle.qml")); widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(widget.window(), 5000)); + QVERIFY(QTest::qWaitForWindowExposed(widget.window())); // Note: send the event to the QWindow, not the QWidget, in order // to simulate the full event processing chain. @@ -516,7 +516,7 @@ void tst_qquickwidget::shortcuts() KeyHandlingWidget widget; widget.setSource(testFileUrl("rectangle.qml")); widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(widget.window(), 5000)); + QVERIFY(QTest::qWaitForWindowExposed(widget.window())); // Send to the widget, verify that the QQuickWindow sees it. @@ -534,14 +534,14 @@ void tst_qquickwidget::enterLeave() QQuickWidget view; view.setSource(testFileUrl("enterleave.qml")); - // Ensure it is not inside the window first + // Ensure the cursor is away from the window first const auto outside = m_availableGeometry.topLeft() + QPoint(50, 50); QCursor::setPos(outside); QTRY_VERIFY(QCursor::pos() == outside); view.move(m_availableGeometry.topLeft() + QPoint(100, 100)); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QQuickItem *rootItem = view.rootObject(); QVERIFY(rootItem); const QPoint frameOffset = view.geometry().topLeft() - view.frameGeometry().topLeft(); @@ -551,7 +551,7 @@ void tst_qquickwidget::enterLeave() QCursor::setPos(view.pos() + QPoint(50, 50) + frameOffset); QTRY_VERIFY(rootItem->property("hasMouse").toBool()); // Now check the leave - QCursor::setPos(view.pos() - QPoint(50, 50)); + QCursor::setPos(outside); QTRY_VERIFY(!rootItem->property("hasMouse").toBool()); } @@ -563,7 +563,7 @@ void tst_qquickwidget::mouseEventWindowPos() quick->setSource(testFileUrl("mouse.qml")); quick->move(50, 50); widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(&widget, 5000)); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); QQuickItem *rootItem = quick->rootObject(); QVERIFY(rootItem); diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index 5190368e20..465bcb53d4 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -546,15 +546,15 @@ int main(int argc, char ** argv) QLocale locale; QTranslator qtTranslator; if (qtTranslator.load(locale, QLatin1String("qt"), QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) - app->installTranslator(&qtTranslator); + QCoreApplication::installTranslator(&qtTranslator); QTranslator translator; if (translator.load(locale, QLatin1String("qmlscene"), QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) - app->installTranslator(&translator); + QCoreApplication::installTranslator(&translator); QTranslator qmlTranslator; if (!options.translationFile.isEmpty()) { if (qmlTranslator.load(options.translationFile)) { - app->installTranslator(&qmlTranslator); + QCoreApplication::installTranslator(&qmlTranslator); } else { fprintf(stderr, "Could not load the translation file \"%s\"\n", qPrintable(options.translationFile)); |