From 5e2d190ebf5d29f975cbffb3bc3a6f4452367994 Mon Sep 17 00:00:00 2001 From: Luigi Toscano Date: Mon, 22 Sep 2014 22:49:30 +0200 Subject: [PATCH] Guard drawText() when X-bitmap fonts are used If the fonts are mapped for some reason to X bitmap fonts, the call to drawText() in the non-GUI thread will produce a crash. Ensure that the rendering of the text is performed only if the threaded font rendering is available - a rare event nowadays, but still possible. CCBUG: 248852 --- generators/dvi/special.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/generators/dvi/special.cpp b/generators/dvi/special.cpp index 4d63e9d67..22ee549fb 100644 --- a/generators/dvi/special.cpp +++ b/generators/dvi/special.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -421,11 +422,17 @@ void dviRenderer::epsf_special(const QString& cp) QFont f = foreGroundPainter->font(); f.setPointSize(8); foreGroundPainter->setFont(f); - if (QFile::exists(EPSfilename)) - foreGroundPainter->drawText (bbox, (int)(Qt::AlignCenter), EPSfilename); - else - foreGroundPainter->drawText (bbox, (int)(Qt::AlignCenter), - i18n("File not found: \n %1", EPSfilename_orig)); + /* if the fonts are mapped for some reason to X bitmap fonts, + the call to drawText() in the non-GUI thread will produce a crash. + Ensure that the rendering of the text is performed only if + the threaded font rendering is available */ + if (QFontDatabase::supportsThreadedFontRendering()) { + if (QFile::exists(EPSfilename)) + foreGroundPainter->drawText (bbox, (int)(Qt::AlignCenter), EPSfilename); + else + foreGroundPainter->drawText (bbox, (int)(Qt::AlignCenter), + i18n("File not found: \n %1", EPSfilename_orig)); + } foreGroundPainter->restore(); }