From 80b42d91a19a0ae9e2c15d9e0a9f828eaa45627d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 2 Feb 2015 11:17:36 +0100 Subject: 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 --- src/svg/qsvghandler.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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,")); -- cgit v1.2.1