Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-65566

SIGSEGV in QFontDatabase when attempting to use QTextDocument::drawContents in a QCoreApplication

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.9.0
    • GUI: Font handling
    • None
    • Ubuntu 16.04.1 on x86_64, also reproducible on i.MX6

    Description

      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();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            komo KOMO Team
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes