summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authoraavit <qt-info@nokia.com>2010-05-05 08:20:03 (GMT)
committeraavit <qt-info@nokia.com>2010-05-05 08:20:03 (GMT)
commit87f7444d2af1299460bdbfc1cbfa903ea504b7e3 (patch)
tree99c5f997f91704d47620607a8b1a6373b1ab6fb3 /src/plugins
parent171d77c62f857bf6fc0761bb62af24251c36053c (diff)
downloadQt-87f7444d2af1299460bdbfc1cbfa903ea504b7e3.zip
Qt-87f7444d2af1299460bdbfc1cbfa903ea504b7e3.tar.gz
Qt-87f7444d2af1299460bdbfc1cbfa903ea504b7e3.tar.bz2
Fixes regression: SVG image loading would fail from QBuffer with pos!=0
Was introduced with 2fe059c. Also now updates pos() as expected after reading in these cases. Autotest added to catch issues where pos != 0, or wrong pos after read. Reviewed-by: Kim
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/imageformats/svg/qsvgiohandler.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp
index 8155569..7b8463d 100644
--- a/src/plugins/imageformats/svg/qsvgiohandler.cpp
+++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp
@@ -82,15 +82,19 @@ bool QSvgIOHandlerPrivate::load(QIODevice *device)
if (q->format().isEmpty())
q->canRead();
+ // # The SVG renderer doesn't handle trailing, unrelated data, so we must
+ // assume that all available data in the device is to be read.
bool res = false;
QBuffer *buf = qobject_cast<QBuffer *>(device);
if (buf) {
- res = r.load(buf->data());
+ const QByteArray &ba = buf->data();
+ res = r.load(QByteArray::fromRawData(ba.constData() + buf->pos(), ba.size() - buf->pos()));
+ buf->seek(ba.size());
} else if (q->format() == "svgz") {
- res = r.load(device->readAll()); // ### can't stream svgz
+ res = r.load(device->readAll());
} else {
xmlReader.setDevice(device);
- res = r.load(&xmlReader); //### doesn't leave pos() correctly
+ res = r.load(&xmlReader);
}
if (res) {