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

QFontMetrics throws exception when passing empty QFont

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P1: Critical
    • None
    • 5.9.4, 5.9.6
    • GUI: Font handling
    • None
    • Windows

    Description

      When an empty `QFont` is passed to `QFontMetrics`, calling 'QFontMetrics::width' throws an exception. Apparently this exception is only thrown in Windows.

      Here's a minimal working example that triggers a crash on Windows (Qt Creator 4.6.2, Qt 5.9.6, msvc2017)

      
      #include <QApplication>
      #include <QFontMetrics>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QFont font("", 0);
          QFontMetrics fm(font);
      
          QString text("testing");
          auto width = fm.width(text);
      
          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
            rui maciel Rui Maciel
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes