summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-08-26 08:07:20 +0200
committerQt by Nokia <qt-info@nokia.com>2011-08-26 14:29:46 +0200
commit22011ece4c48ddd7887d7527d558dfb95fd9ceb7 (patch)
tree4deb7b0f832ff8976c4729c13fb9c8fc5cf8565f /src/gui
parent580bd22dc6162f3da2b829093cb14e898f2f628f (diff)
Fix crash when fallback font is not #0 in multi font engine
Easily reproducible by testing Chinese with the threaded renderer. The multi engine would then have a list of engines with a single item, but the glyphs might belong to e.g. engine 11. In that case, engine() would assert when it couldn't find the engine if the layout had been done in a different thread. We force the loading of the required engine if it's not already loaded. Note that this fix does not work on Mac, as loadEngine() will crash there, so the layout has to be done in the same thread as the rendering, since loading the engines is part of the layout process. Task-number: QTBUG-21112 Change-Id: I71cc396664e3b95fbb4815a90873457e1f89528e Reviewed-on: http://codereview.qt.nokia.com/3631 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qfontengine_p.h5
-rw-r--r--src/gui/text/qtextlayout.cpp2
2 files changed, 7 insertions, 0 deletions
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 5f779e155a..e9a8d6f607 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -434,6 +434,11 @@ public:
QFontEngine *engine(int at) const
{Q_ASSERT(at < engines.size()); return engines.at(at); }
+ inline void ensureEngineAt(int at)
+ {
+ if (at >= engines.size() || engines.at(at) == 0)
+ loadEngine(at);
+ }
protected:
friend class QPSPrintEnginePrivate;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 8c5e63da54..d253c02052 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2305,6 +2305,7 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
continue;
QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
+ multiFontEngine->ensureEngineAt(which);
glyphRuns.append(glyphRunWithInfo(multiFontEngine->engine(which),
subLayout, pos, flags, x, width));
for (int i = 0; i < subLayout.numGlyphs; i++) {
@@ -2317,6 +2318,7 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
}
QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
+ multiFontEngine->ensureEngineAt(which);
QGlyphRun glyphRun = glyphRunWithInfo(multiFontEngine->engine(which),
subLayout, pos, flags, x, width);
if (!glyphRun.isEmpty())