diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-09-02 17:27:57 +1000 |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2010-09-03 13:23:33 +1000 |
commit | 41b70c74dee1d3ae9ca33a007b0afe9cee51a980 (patch) | |
tree | fc52cbefef70816b21128c92b4b5c3d44a417be5 /tests | |
parent | 1c119d7ba29cd034f57d32752e09cadfe0f58298 (diff) |
Don't overflow the unreferenced cost counter
QTBUG-13345
(cherry picked from commit b6d47ea4872e188d8da6886cb1922f1a89245825)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp index 6b3622495e..b20d8ec023 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp +++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp @@ -42,6 +42,7 @@ #include <QtTest/QtTest> #include <private/qdeclarativepixmapcache_p.h> #include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativeimageprovider.h> #include <QNetworkReply> #include "testhttpserver.h" #include "../../../shared/util.h" @@ -72,6 +73,7 @@ private slots: void parallel_data(); void massive(); void cancelcrash(); + void shrinkcache(); private: QDeclarativeEngine engine; @@ -326,6 +328,31 @@ void tst_qdeclarativepixmapcache::cancelcrash() } } +class MyPixmapProvider : public QDeclarativeImageProvider +{ +public: + MyPixmapProvider() + : QDeclarativeImageProvider(Pixmap) {} + + virtual QPixmap requestPixmap(const QString &d, QSize *, const QSize &) { + QPixmap pix(800, 600); + pix.fill(Qt::red); + return pix; + } +}; + +// QTBUG-13345 +void tst_qdeclarativepixmapcache::shrinkcache() +{ + QDeclarativeEngine engine; + engine.addImageProvider(QLatin1String("mypixmaps"), new MyPixmapProvider); + + for (int ii = 0; ii < 4000; ++ii) { + QUrl url("image://mypixmaps/" + QString::number(ii)); + QDeclarativePixmap p(&engine, url); + } +} + QTEST_MAIN(tst_qdeclarativepixmapcache) #include "tst_qdeclarativepixmapcache.moc" |