aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktext.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-03-02 13:17:04 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-03-02 14:51:41 +0000
commitac4dcc585f4fb02b9b04867c75a883e4ad23693e (patch)
tree4b65a37b431843c6964b6c40148a8d93eb1cdd7f /src/quick/items/qquicktext.cpp
parent726eaaeeeede086ed341899b8ee0c1570e6bf6f5 (diff)
Avoid assert in rich text when img width is invalid
If you set the width or height of an <img> tag to something invalid, this will be registered as -2 by the HTML parser. We should treat this case the same as if there is no width/height specified and use the implicit size instead. [ChangeLog][Text] Fixed assert when setting an invalid width or height on an <img> tag in a text element. Change-Id: Iae8c33fa184316632f72318e71f26ab005645a21 Task-number: QTBUG-44743 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/items/qquicktext.cpp')
-rw-r--r--src/quick/items/qquicktext.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 9311b9d9c9..1919ba9e79 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -144,10 +144,10 @@ QSizeF QQuickTextDocumentWithImageResources::intrinsicSize(
if (format.isImageFormat()) {
QTextImageFormat imageFormat = format.toImageFormat();
- const bool hasWidth = imageFormat.hasProperty(QTextFormat::ImageWidth);
const int width = qRound(imageFormat.width());
- const bool hasHeight = imageFormat.hasProperty(QTextFormat::ImageHeight);
+ const bool hasWidth = imageFormat.hasProperty(QTextFormat::ImageWidth) && width > 0;
const int height = qRound(imageFormat.height());
+ const bool hasHeight = imageFormat.hasProperty(QTextFormat::ImageHeight) && height > 0;
QSizeF size(width, height);
if (!hasWidth || !hasHeight) {