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

QWin32PrintEngine crashes (due to missing fonts?)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 6.5.1
    • GUI: Printing
    • None
    • Windows 10 Enterprise, 22H2
    • Windows

    Description

      While trying to print with QPrinter on Windows 10 22H2, the program crashes with:

      ASSERT: "!isEmpty()" in file [...]/qtbase/src/corelib/tools/qliste.h, line 607 

      This is due to the following code bit:

      QDataStream &operator<<(QDataStream &s, const QFont &font)
      {
        if (s.version() == 1) {
          s << font.d->request.families.first().toLatin1();
        } else {
          s << font.d->request.families.first(); // crashes here
        [...]
      }

      The call to first() crashes if families is empty. I suppose this is an illegal state for QFont to be in though - I'm not quite sure how this happens though. I'm not sure if I'm just missing some font on my Windows install, this is just a stock install. This happens while calling QPainter::begin(), so I don't think it has loaded the document yet, so maybe it's not actually due to missing fonts though?

      Here's the code:

      class Printer : QPrinter {[...]};
      
      void Printer::print() {
        this->setDocName("Untitled");
        this->setColorMode(this->config.chromaticity);
        this->setPageOrientation(this->config.orientation);
        this->setCopyCount(this->config.copies);
        this->setDuplex(this->config.side);
        this->setResolution(300);
        this->setPrinterName(printerInfo->printerName());
        if (!this->isValid()) {
          throw PrintException();
        }
      
        QPainter painter;
        if(!painter.begin(this)) { // crashes here
          throw PrintException();
        }
      }

      And here's the backtrace, tested with both the Conan package and the official Qt package.

      Qt6Cored.dll!qt_message_fatal(QtMsgType __formal, const QMessageLogContext & context, const QString & message) Line 2042 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\corelib\global\qlogging.cpp:2042)
      Qt6Cored.dll!QMessageLogger::fatal(const char * msg, ...) Line 935 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\corelib\global\qlogging.cpp:935)
      Qt6Cored.dll!qt_assert(const char * assertion, const char * file, int line) Line 67 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\corelib\global\qassert.cpp:67)
      Qt6Guid.dll!QList<QString>::first() Line 607 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\corelib\tools\qlist.h:607)
      Qt6Guid.dll!operator<<(QDataStream & s, const QFont & font) Line 2290 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\gui\text\qfont.cpp:2290)
      Qt6Guid.dll!QPicturePaintEngine::updateFont(const QFont & font) Line 216 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\gui\image\qpaintengine_pic.cpp:216)
      Qt6Guid.dll!QPicturePaintEngine::updateState(const QPaintEngineState & state) Line 489 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\gui\image\qpaintengine_pic.cpp:489)
      Qt6Guid.dll!QPaintEngine::syncState() Line 272 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\gui\painting\qpaintengine.cpp:272)
      Qt6PrintSupportd.dll!QAlphaPaintEngine::flushAndInit(bool init) Line 330 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\printsupport\kernel\qpaintengine_alpha.cpp:330)
      Qt6PrintSupportd.dll!QAlphaPaintEngine::begin(QPaintDevice * pdev) Line 57 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\printsupport\kernel\qpaintengine_alpha.cpp:57)
      Qt6PrintSupportd.dll!QWin32PrintEngine::begin(QPaintDevice * pdev) Line 81 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\printsupport\platform\windows\qprintengine_win.cpp:81)
      Qt6Guid.dll!QPainter::begin(QPaintDevice * pd) Line 1790 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\gui\painting\qpainter.cpp:1790)
      print.exe!libprint::PrintOrder::print() Line 126 (c:\Users\vagrant\Projects\ds4-print-server-qt\src\PrintOrder.cpp:126)
      print.exe!libprint::WebsocketClient::executePrintOrder(const std::shared_ptr<libprint::PrintOrder> & order) Line 88 (c:\Users\vagrant\Projects\ds4-print-server-qt\src\WebSocketClient.cpp:88)
      print.exe!libprint::WebsocketClient::onTextMessageReceived(const QString & message) Line 64 (c:\Users\vagrant\Projects\ds4-print-server-qt\src\WebSocketClient.cpp:64)
      print.exe!QtPrivate::FunctorCall<QtPrivate::IndexesList<0>,QtPrivate::List<QString const &>,void,void (__cdecl libprint::WebsocketClient::*)(QString const &)>::call(void(libprint::WebsocketClient::*)(const QString &) f, libprint::WebsocketClient * o, void * * arg) Line 135 (c:\Users\vagrant\.conan2\p\b\qtfce70b96b2bba\p\include\QtCore\qobjectdefs_impl.h:135)
      print.exe!QtPrivate::FunctionPointer<void (__cdecl libprint::WebsocketClient::*)(QString const &)>::call<QtPrivate::List<QString const &>,void>(void(libprint::WebsocketClient::*)(const QString &) f, libprint::WebsocketClient * o, void * * arg) Line 173 (c:\Users\vagrant\.conan2\p\b\qtfce70b96b2bba\p\include\QtCore\qobjectdefs_impl.h:173)
      print.exe!QtPrivate::QSlotObject<void (__cdecl libprint::WebsocketClient::*)(QString const &),QtPrivate::List<QString const &>,void>::impl(int which, QtPrivate::QSlotObjectBase * this_, QObject * r, void * * a, bool * ret) Line 385 (c:\Users\vagrant\.conan2\p\b\qtfce70b96b2bba\p\include\QtCore\qobjectdefs_impl.h:385)
      Qt6Cored.dll!QtPrivate::QSlotObjectBase::call(QObject * r, void * * a) Line 363 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\corelib\kernel\qobjectdefs_impl.h:363)
      Qt6Cored.dll!doActivate<0>(QObject * sender, int signal_index, void * * argv) Line 3992 (c:\Users\vagrant\.conan2\p\qtaabfba1f9d5d7\s\src\qtbase\src\corelib\kernel\qobject.cpp:3992) 

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            rasmus.thomsen Rasmus Thomsen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes