Fix divide by zero when glyphWidth is 0
authorJiang Jiang <jiang.jiang@nokia.com>
Mon, 27 Feb 2012 08:51:46 +0000 (09:51 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 28 Feb 2012 00:12:08 +0000 (01:12 +0100)
Change-Id: Ic0108b76b8d73cc977f8d64e036a65cb93db4684
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
src/gui/text/qtextengine.cpp

index 3017075..c63f0fe 100644 (file)
@@ -2702,6 +2702,8 @@ int QTextEngine::positionInLigature(const QScriptItem *si, int end,
         QFixed glyphWidth = glyphs.effectiveAdvance(glyph_pos);
         // the approximate width of each individual element of the ligature
         QFixed perItemWidth = glyphWidth / clusterLength;
+        if (perItemWidth <= 0)
+            return si->position + clusterStart;
         QFixed left = x > edge ? edge : edge - glyphWidth;
         int n = ((x - left) / perItemWidth).floor().toInt();
         QFixed dist = x - left - n * perItemWidth;