Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
4.6.3
-
None
-
None
-
ubuntu 2.6.32-24-generic #39-Ubuntu SMP Wed Jul 28 06:07:29 UTC 2010 i686 GNU/Linux
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3)
Description
When using QFontMetrics in a non-GUI application on X11:
XListFonts is called with an invalid X11 display which leads to a crash. XListFonts should not be called if there is no valid X11 display (since GUIEnbaled == false)
The following code reproduces the error:
#include <QApplication> #include <QFont> #include <QFontMetrics> void testFontHeight() { #if defined(QT_CORE_LIB) QFont font("Courier New", 10); font.setFixedPitch(true); QFontMetrics fontMetrics(font); int iHeight = fontMetrics.height(); int iAscent = fontMetrics.ascent(); int iDescent = fontMetrics.descent(); Q_ASSERT( iHeight == iAscent + iDescent + 1 ); #endif } int main(int argc, char *argv[]) { QApplication a(argc, argv, false); testFontHeight(); return 0; }
Here is the backtrace:
#0 XListFonts (dpy=0x0, pattern=0x9114108 "-*-Courier New-*-*-*-*-*-*-*-*-*-*-*-*", maxNames=65535, actualCount=0xbfffe8c8) at ../../src/FontNames.c:52 #1 0x08509b39 in loadXlfds(char const*, int) () #2 0x0850a3d0 in load(QString const&, int, bool) () #3 0x0850e187 in QFontDatabase::loadXlfd(int, int, QFontDef const&, int) () #4 0x0850fbf7 in QFontDatabase::load(QFontPrivate const*, int) () #5 0x084f304c in QFontPrivate::engineForScript(int) const () #6 0x08502ef2 in QFontMetrics::height() const ()
Attachments
Issue Links
- is replaced by
-
QTBUG-10448 Segmentation fault in QFontMetrics::width()
- Closed