aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickimageprovider
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2021-12-15 11:42:23 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-12-17 01:17:55 +0000
commit4d5420a5cda1d281e8c062acc0dc1cdc1a9cfeb0 (patch)
tree8c7558e6835e17fa41ec47b13bac1dc6cb035c4a /tests/auto/quick/qquickimageprovider
parent90f0e95501a0765deba8e26a60ca9ad5a8717f04 (diff)
tst_qquickimageprovider: fix some memleaks
QTest::toString() returns a heap-allocated char pointer that must be delete[]ed after use. Instead of abusing QTest::toString(), use QTest::addRow(), which features printf-style formatting for the label. Found by lsan, which was going completely wild. Change-Id: I53f2aa1dce7a128c964a2b02420c65a410bf9b15 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e95a43fb7666d6cf6095598c8bb9bbc1de9c3eb3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/quick/qquickimageprovider')
-rw-r--r--tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
index 49e94432e4..1a479f7c0c 100644
--- a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
+++ b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
@@ -72,7 +72,7 @@ private slots:
private:
QString newImageFileName() const;
- void fillRequestTestsData(const QString &id);
+ void fillRequestTestsData(const char *id);
void runTest(bool async, QQuickImageProvider *provider);
};
@@ -161,7 +161,7 @@ QString tst_qquickimageprovider::newImageFileName() const
return QString("image://test/image-%1.png").arg(count++);
}
-void tst_qquickimageprovider::fillRequestTestsData(const QString &id)
+void tst_qquickimageprovider::fillRequestTestsData(const char *id)
{
QTest::addColumn<QString>("source");
QTest::addColumn<QString>("imageId");
@@ -170,39 +170,39 @@ void tst_qquickimageprovider::fillRequestTestsData(const QString &id)
QTest::addColumn<QString>("error");
QString fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " simple test"))
+ QTest::addRow("%s simple test", id)
<< "image://test/" + fileName << fileName << "" << QSize(100,100) << "";
fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " simple test with capitalization"))//As it's a URL, should make no difference
+ QTest::addRow("%s simple test with capitalization", id)//As it's a URL, should make no difference
<< "image://Test/" + fileName << fileName << "" << QSize(100,100) << "";
fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with no id"))
+ QTest::addRow("%s url with no id", id)
<< "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << "";
fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with path"))
+ QTest::addRow("%s url with path", id)
<< "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << "";
fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with fragment"))
+ QTest::addRow("%s url with fragment", id)
<< "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << "";
fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with query"))
+ QTest::addRow("%s url with query", id)
<< "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName
<< "" << QSize(100,100) << "";
fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " scaled image"))
+ QTest::addRow("%s scaled image", id)
<< "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << "";
- QTest::newRow(QTest::toString(id + " missing"))
+ QTest::addRow("%s missing", id)
<< "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100)
<< "<Unknown File>:2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png";
- QTest::newRow(QTest::toString(id + " unknown provider"))
+ QTest::addRow("%s unknown provider", id)
<< "image://bogus/exists.png" << "" << "" << QSize()
<< "<Unknown File>:2:1: QML Image: Invalid image provider: image://bogus/exists.png";
}