From: Tasuku Suzuki Date: Sat, 8 Jun 2013 06:53:09 +0000 (+0900) Subject: fix case insensitive issue with image provider id X-Git-Tag: upstream/5.2.1~677^2~93 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d4b006181d009e6245d5d38c7798603ddcab06a;p=platform%2Fupstream%2Fqtdeclarative.git fix case insensitive issue with image provider id Task-number: QTBUG-31614 Change-Id: I866df6e3ed6226b443640a51f66a3dbb92b31249 Reviewed-by: Alan Alpert --- diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 6466213..b36f35f 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1065,7 +1065,7 @@ QQmlImageProviderBase *QQmlEngine::imageProvider(const QString &providerId) cons { Q_D(const QQmlEngine); QMutexLocker locker(&d->mutex); - return d->imageProviders.value(providerId).data(); + return d->imageProviders.value(providerId.toLower()).data(); } /*! @@ -1077,7 +1077,7 @@ void QQmlEngine::removeImageProvider(const QString &providerId) { Q_D(QQmlEngine); QMutexLocker locker(&d->mutex); - d->imageProviders.take(providerId); + d->imageProviders.take(providerId.toLower()); } /*! diff --git a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp index a790c7b..3eea3c9 100644 --- a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp +++ b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp @@ -71,6 +71,9 @@ private slots: void removeProvider_data(); void removeProvider(); + void imageProviderId_data(); + void imageProviderId(); + void threadTest(); private: @@ -372,6 +375,31 @@ void tst_qquickimageprovider::removeProvider() delete obj; } +void tst_qquickimageprovider::imageProviderId_data() +{ + QTest::addColumn("providerId"); + + QTest::newRow("lowercase") << QStringLiteral("imageprovider"); + QTest::newRow("CamelCase") << QStringLiteral("ImageProvider"); + QTest::newRow("UPPERCASE") << QStringLiteral("IMAGEPROVIDER"); +} + +void tst_qquickimageprovider::imageProviderId() +{ + QFETCH(QString, providerId); + + QQmlEngine engine; + + bool deleteWatch = false; + TestQImageProvider *provider = new TestQImageProvider(&deleteWatch); + + engine.addImageProvider(providerId, provider); + QVERIFY(engine.imageProvider(providerId) != 0); + + engine.removeImageProvider(providerId); + QVERIFY(deleteWatch); +} + class TestThreadProvider : public QQuickImageProvider { public: