From f6bbeeb417102c61e8bf23f41e412ed9753a348d Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 24 Apr 2018 11:35:43 +0200 Subject: Normalize URL before loading types This prevents loading of types with slightly different paths multiple times, like "qrc:/One.qml" and "qrc:///One.qml". Task-number: QTBUG-65723 Change-Id: I6e26db6d1d271b2ed37b97eb990618843e99c372 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlengine/data/qrcurls.js | 1 + tests/auto/qml/qqmlengine/data/qrcurls.qml | 4 ++++ tests/auto/qml/qqmlengine/qqmlengine.pro | 4 ++++ tests/auto/qml/qqmlengine/tst_qqmlengine.cpp | 27 +++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 tests/auto/qml/qqmlengine/data/qrcurls.js create mode 100644 tests/auto/qml/qqmlengine/data/qrcurls.qml (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmlengine/data/qrcurls.js b/tests/auto/qml/qqmlengine/data/qrcurls.js new file mode 100644 index 0000000000..15a4d5a70c --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/qrcurls.js @@ -0,0 +1 @@ +function someFunction() {} diff --git a/tests/auto/qml/qqmlengine/data/qrcurls.qml b/tests/auto/qml/qqmlengine/data/qrcurls.qml new file mode 100644 index 0000000000..e879577e10 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/qrcurls.qml @@ -0,0 +1,4 @@ +import QtQml 2.0 + +QtObject { +} diff --git a/tests/auto/qml/qqmlengine/qqmlengine.pro b/tests/auto/qml/qqmlengine/qqmlengine.pro index 8d1e149d62..d2eb92bfd5 100644 --- a/tests/auto/qml/qqmlengine/qqmlengine.pro +++ b/tests/auto/qml/qqmlengine/qqmlengine.pro @@ -12,3 +12,7 @@ boot2qt: { # GC corruption test is too heavy for qemu-arm DEFINES += SKIP_GCCORRUPTION_TEST } + +RESOURCES += \ + data/qrcurls.qml \ + data/qrcurls.js diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 52e18011cb..6ae786469d 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -77,6 +77,7 @@ private slots: void testGCCorruption(); void testGroupedPropertyRevisions(); void componentFromEval(); + void qrcUrls(); public slots: QObject *createAQObjectForOwnershipTest () @@ -897,6 +898,32 @@ void tst_qqmlengine::componentFromEval() QVERIFY(!item.isNull()); } +void tst_qqmlengine::qrcUrls() +{ + QQmlEngine engine; + QQmlEnginePrivate *pEngine = QQmlEnginePrivate::get(&engine); + + { + QQmlRefPointer oneQml(pEngine->typeLoader.getType(QUrl("qrc:/qrcurls.qml")), + QQmlRefPointer::Adopt); + QVERIFY(oneQml != nullptr); + QQmlRefPointer twoQml(pEngine->typeLoader.getType(QUrl("qrc:///qrcurls.qml")), + QQmlRefPointer::Adopt); + QVERIFY(twoQml != nullptr); + QCOMPARE(oneQml, twoQml); + } + + { + QQmlRefPointer oneJS(pEngine->typeLoader.getType(QUrl("qrc:/qrcurls.js")), + QQmlRefPointer::Adopt); + QVERIFY(oneJS != nullptr); + QQmlRefPointer twoJS(pEngine->typeLoader.getType(QUrl("qrc:///qrcurls.js")), + QQmlRefPointer::Adopt); + QVERIFY(twoJS != nullptr); + QCOMPARE(oneJS, twoJS); + } +} + QTEST_MAIN(tst_qqmlengine) #include "tst_qqmlengine.moc" -- cgit v1.2.3