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
remotes/origin/KDE/4.14
Luigi Toscano 12 years ago
parent d888b20483
commit 5e2d190ebf
  1. 17
      generators/dvi/special.cpp

@ -20,6 +20,7 @@
#include <kmimetype.h>
#include <QFile>
#include <QFontDatabase>
#include <QImage>
#include <QPainter>
@ -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();
}

Loading…
Cancel
Save