-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.9.0
-
None
-
Ubuntu 16.04.1 on x86_64, also reproducible on i.MX6
QTextDocument::drawContents needs a QGuiApplication to work, because it uses QFontDatabase. The documentation of all the classes involved in the example below fails to mention this (AFAICS). I would expect the unapplicable method (in this case QTextDocument::drawContents, perhaps there are others?) to return an error, but instead it makes the application crash with a segfault in QFontDatabase::findFont(QFontDef& const, int).
#include <QCoreApplication>
#include <QTextDocument>
#include <QPainter>
#include <QImage>
#include <QRect>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTextDocument d;
QImage image(128, 128, QImage::Format_ARGB32);
QPainter p(&image);
d.drawContents(&p, QRect(0, 0, 128, 128));
return a.exec();
}