summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-05-20 12:33:37 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-05-20 13:05:39 (GMT)
commitef8cd7f2e68d6d34d70c3a12e82a67ed16b92b72 (patch)
tree0487783dec6fccc9b0d33db42330f3a957065677
parent2c1d1c136102a17eef9ae3c4e9f0cf01338306ae (diff)
downloadQt-ef8cd7f2e68d6d34d70c3a12e82a67ed16b92b72.zip
Qt-ef8cd7f2e68d6d34d70c3a12e82a67ed16b92b72.tar.gz
Qt-ef8cd7f2e68d6d34d70c3a12e82a67ed16b92b72.tar.bz2
Fix crash when using fonts in non-gui QApplication
XLFD requires a DISPLAY connection to work. We would get crashes in a QApplication with GUI disabled when: 1. Not using FontConfig, or 2. Falling back to XLFD for bitmap fonts that require scaling. The patch disables paths to loadXlfd() when GUI is disabled. This means that in XLFD, we will always get a box font, which is the same behavior as when using fonts outside the main thread. There doesn't seem to be any way around this. With FontConfig, we will use the font it returns, even if it's a slightly wrong size. Main consequence will be for using bitmap fonts for printing on a highres printer in a non-gui application. Again, there does not seem to be any way around this. NOTE: I've also added a catch to avoid going into loadXlfd() in the fallback if we're not on the main thread, since this was missing. Task-number: QTBUG-10448 Reviewed-by: Trond
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index 3b2e4e9..a7aa2ce 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/gui/text/qfontdatabase_x11.cpp
@@ -78,6 +78,9 @@ QT_BEGIN_NAMESPACE
extern double qt_pointSize(double pixelSize, int dpi);
extern double qt_pixelSize(double pointSize, int dpi);
+// from qapplication.cpp
+extern bool qt_is_gui_used;
+
static inline void capitalize (char *s)
{
bool space = true;
@@ -1938,7 +1941,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
} else if (X11->has_fontconfig) {
fe = loadFc(d, script, req);
- if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize) {
+ if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize && mainThread && qt_is_gui_used) {
QFontEngine *xlfdFontEngine = loadXlfd(d->screen, script, req);
if (xlfdFontEngine->fontDef.family == fe->fontDef.family) {
delete fe;
@@ -1950,7 +1953,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
#endif
- } else if (mainThread) {
+ } else if (mainThread && qt_is_gui_used) {
fe = loadXlfd(d->screen, script, req);
}
if (!fe) {