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

Error deserializing QFont (from 5.15 to 6.2)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 6.2.3, 6.3.0 Alpha
    • 6.2.0
    • GUI: Font handling
    • None
    • Windows 10, Visual Studio 2019
    • Windows
    • 71faedc5b4c1f95f47fba6d65b8f619602964d6f (qt/qtbase/dev) c13101b0b33f557763051953a71a29b540624036 (qt/qtbase/6.2)

    Description

      I get an error if I try to deserialize a QFont with Qt 6.2.0, serialized with Qt 5.15.0. I get a font with an empty family (I set the correct version on QDataStream). Also, if I set the deserialized font to a QFontComboBox, the application crashes.

      The following code snippets show the error.

      Serialize a QFont using Qt 5.15.0

      //test write Qt 5.15.0
      QFont font("Verdana");
      font.setPointSize(12);
      qDebug() << font.family();
      qDebug() << font.pointSize();
      QFile file("test_font.bin");
      file.open(QIODevice::WriteOnly);
      QDataStream ds(&file);
      ds << font;
      file.close();
      

       

      output:

      "Verdana"
      12

       

      Deserialize using Qt 6.2.0

      //test read Qt 6.2.0
      QFile file("test_font.bin");
      file.open(QIODevice::ReadOnly);
      QDataStream ds(&file);
      ds.setVersion(QDataStream::Qt_5_15);
      QFont font;
      ds >> font;
      file.close();
      qDebug() << font.family();
      qDebug() << font.pointSize();
      QFontComboBox* fontCB = new QFontComboBox();
      fontCB->setCurrentFont(font); //crash!!
      

      Output:

      ""
      12
      ASSERT: "!isEmpty()" in file C:\Users\qt\work\qt\qtbase\include\QtCore\../../src/corelib/tools/qlist.h, line 570
      Debug Error!
      Program: J:\VC2015\Qt.6.2.0\6.2.0\msvc2019_64\bin\Qt6Cored.dll
      Module: 6.2.0
      File: C:\Users\qt\work\qt\qtbase\include\QtCore\../../src/corelib/tools/qlist.h
      Line: 570
      ASSERT: "!isEmpty()" in file C:\Users\qt\work\qt\qtbase\include\QtCore\../../src/corelib/tools/qlist.h, line 570
      

       

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-97995
          # Subject Branch Project Status CR V

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              puffosauro Fabio Dago
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes