summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-09-02 07:27:57 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-09-02 07:27:57 (GMT)
commitb6d47ea4872e188d8da6886cb1922f1a89245825 (patch)
treeec4818282531b9cd1689ba4a61b32bee48080c8d /tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
parentce698d243f31d2b9adcdf2b6b40f5844c200b159 (diff)
downloadQt-b6d47ea4872e188d8da6886cb1922f1a89245825.zip
Qt-b6d47ea4872e188d8da6886cb1922f1a89245825.tar.gz
Qt-b6d47ea4872e188d8da6886cb1922f1a89245825.tar.bz2
Don't overflow the unreferenced cost counter
QTBUG-13345
Diffstat (limited to 'tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp27
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 6b36224..b20d8ec 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"