summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Volkov <a.volkov@rusbitech.ru>2016-10-19 15:32:03 +0300
committerAlexander Volkov <a.volkov@rusbitech.ru>2016-10-27 12:44:20 +0000
commitaed47778b6677f3a4ca5f87e806191f25de3c6a9 (patch)
tree8830d3b4d65a986d7899111b90518c701acb8009
parent78bc427395116bfaf3d99134f42aec5310020f8e (diff)
downloadqtsvg-aed47778b6677f3a4ca5f87e806191f25de3c6a9.tar.gz
Ignore .svgz images unless compression is enabled
The imageformats plugin was trying to pass them off to QSvgRenderer, which can't handle them when QT_NO_COMPRESS is defined. Change-Id: I92241370d8fd4ed2328fb13a01306fa8a7e5ef6e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
-rw-r--r--src/plugins/imageformats/svg/main.cpp4
-rw-r--r--src/plugins/imageformats/svg/qsvgiohandler.cpp13
2 files changed, 15 insertions, 2 deletions
diff --git a/src/plugins/imageformats/svg/main.cpp b/src/plugins/imageformats/svg/main.cpp
index bf908f9..8eb80b3 100644
--- a/src/plugins/imageformats/svg/main.cpp
+++ b/src/plugins/imageformats/svg/main.cpp
@@ -62,7 +62,11 @@ QStringList QSvgPlugin::keys() const
QImageIOPlugin::Capabilities QSvgPlugin::capabilities(QIODevice *device, const QByteArray &format) const
{
+#ifndef QT_NO_COMPRESS
if (format == "svg" || format == "svgz")
+#else
+ if (format == "svg")
+#endif
return Capabilities(CanRead);
if (!format.isEmpty())
return 0;
diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp
index 8a9cbb2..7a9c337 100644
--- a/src/plugins/imageformats/svg/qsvgiohandler.cpp
+++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp
@@ -82,8 +82,10 @@ bool QSvgIOHandlerPrivate::load(QIODevice *device)
const QByteArray &ba = buf->data();
res = r.load(QByteArray::fromRawData(ba.constData() + buf->pos(), ba.size() - buf->pos()));
buf->seek(ba.size());
+#ifndef QT_NO_COMPRESS
} else if (q->format() == "svgz") {
res = r.load(device->readAll());
+#endif
} else {
xmlReader.setDevice(device);
res = r.load(&xmlReader);
@@ -119,10 +121,13 @@ bool QSvgIOHandler::canRead() const
return true; // Will happen if we have been asked for the size
QByteArray buf = device()->peek(8);
+#ifndef QT_NO_COMPRESS
if (buf.startsWith("\x1f\x8b")) {
setFormat("svgz");
return true;
- } else if (buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--")) {
+ } else
+#endif
+ if (buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--")) {
setFormat("svg");
return true;
}
@@ -251,7 +256,11 @@ bool QSvgIOHandler::supportsOption(ImageOption option) const
bool QSvgIOHandler::canRead(QIODevice *device)
{
QByteArray buf = device->peek(8);
- return buf.startsWith("\x1f\x8b") || buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--");
+ return
+#ifndef QT_NO_COMPRESS
+ buf.startsWith("\x1f\x8b") ||
+#endif
+ buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--");
}
QT_END_NAMESPACE