summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPalo Kisa <palo.kisa@gmail.com>2018-01-08 21:35:32 (GMT)
committerPalo Kisa <palo.kisa@gmail.com>2018-01-10 12:34:26 (GMT)
commitb9cddbd84b74fdda30190800ed827dc80aa65f6c (patch)
tree80c35b8a1baa6816d01de5a48e249b52a7ee6c28
parent2e719713be8ac3b1e26b23221f12db136d9d5103 (diff)
downloadqtsvg-b9cddbd84b74fdda30190800ed827dc80aa65f6c.tar.gz
svgiconengine: Fix isNull() for deserialized icons
In 4a9470e55ce08752501868c60762268fdf2c44af there was introduced specific isNull() implementation for QSvgIconEngine. But the existing check was not sufficient for the scenarios where the QIcon is constructed by deserialization from QDataStream (from previously serialized valid svg QIcon). We also need to check the svgBuffers as the previously serialized svgFiles are silently ignored by QSvgIconEngine::read(). Change-Id: Id64ce233baead053c8b5ca61f1d416e46a8c6088 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: David Edmundson <davidedmundson@kde.org>
-rw-r--r--src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp2
-rw-r--r--tests/auto/qicon_svg/tst_qicon_svg.cpp10
2 files changed, 11 insertions, 1 deletions
diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
index 734f4bb..0c54e0e 100644
--- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
+++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
@@ -378,7 +378,7 @@ bool QSvgIconEngine::write(QDataStream &out) const
void QSvgIconEngine::virtual_hook(int id, void *data)
{
if (id == QIconEngine::IsNullHook) {
- *reinterpret_cast<bool*>(data) = d->svgFiles.isEmpty() && !d->addedPixmaps;
+ *reinterpret_cast<bool*>(data) = d->svgFiles.isEmpty() && !d->addedPixmaps && (!d->svgBuffers || d->svgBuffers->isEmpty());
}
QIconEngine::virtual_hook(id, data);
}
diff --git a/tests/auto/qicon_svg/tst_qicon_svg.cpp b/tests/auto/qicon_svg/tst_qicon_svg.cpp
index 170ec37..0875ee1 100644
--- a/tests/auto/qicon_svg/tst_qicon_svg.cpp
+++ b/tests/auto/qicon_svg/tst_qicon_svg.cpp
@@ -152,6 +152,16 @@ void tst_QIcon_Svg::isNull()
//valid svg, we're not null
QIcon icon(prefix + "heart.svg");
QVERIFY(!icon.isNull());
+
+ // check for non null of serialized/deserialized valid icon
+ QByteArray buf;
+ QDataStream out(&buf, QIODevice::WriteOnly);
+ out << icon;
+
+ QIcon icon2;
+ QDataStream in(buf);
+ in >> icon2;
+ QVERIFY(!icon2.isNull());
}
{
//invalid svg, but a pixmap added means we're not null