summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2015-02-02 11:17:36 +0100
committerAndy Shaw <andy.shaw@digia.com>2015-02-04 09:00:51 +0000
commit80b42d91a19a0ae9e2c15d9e0a9f828eaa45627d (patch)
treeeafa08c1b17c1e102ee9ceb2ac5181bbfd4c6c3b
parent14ac4816796fdfa0e45a6a6a69da0956860a5eb1 (diff)
downloadqtsvg-80b42d91a19a0ae9e2c15d9e0a9f828eaa45627d.tar.gz
Be more informative when a referenced image cannot be parsed
If the filename or the width/height is not valid then we bail out earlier instead of trying to create an image based on the information given. This saves a bit of processing time and also allows for giving more indication as to where the problem comes from. Change-Id: I3d11aa57c0cb965159aa9e42e905ef13ba55988f Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
-rw-r--r--src/svg/qsvghandler.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index 8e30428..ba6a919 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -2684,8 +2684,16 @@ static QSvgNode *createImageNode(QSvgNode *parent,
qreal nheight = parseLength(height, type, handler);
nheight = convertToPixels(nheight, false, type);
-
filename = filename.trimmed();
+ if (filename.isEmpty()) {
+ qWarning() << "QSvgHandler: Image filename is empty";
+ return 0;
+ }
+ if (nwidth <= 0 || nheight <= 0) {
+ qWarning() << "QSvgHandler: Width or height for" << filename << "image was not greater than 0";
+ return 0;
+ }
+
QImage image;
if (filename.startsWith(QLatin1String("data"))) {
int idx = filename.lastIndexOf(QLatin1String("base64,"));