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

Crash when restoring a QDockAreaLayout

    XMLWordPrintable

Details

    • Windows
    • 53c8d0d40b (qt/qtbase/dev) 53c8d0d40b (qt/tqtc-qtbase/dev) 8102ac4143 (qt/qtbase/6.3) 8102ac4143 (qt/tqtc-qtbase/6.3) bcff7f13fd (qt/tqtc-qtbase/6.2)

    Description

      QMainWindow::restoreState crashes when a QDockWidget is restored on a screen that moved.

       

      Repro:

      • Move a QDockWidget outside the QMainWindow, on a secondary screen
      • Save the layout and exit
      • Move the secondardy screen (for instance, if it was on the right, move it on the top). Or change your main monitor from 4K to FullHD (happens a lot to me)
      • Restore
      • -> crash

      See attachement for standalone repro.

       

      The callstack is:

      > Qt6Widgetsd.dll!QDockAreaLayout::constrainedRect(QRect rect, QWidget * widget) Ligne 3032 C++
      Qt6Widgetsd.dll!QDockAreaLayoutInfo::restoreState(QDataStream & stream, QList<QDockWidget *> & widgets, bool testing) Ligne 1941 C++
      Qt6Widgetsd.dll!QDockAreaLayout::restoreState(QDataStream & stream, const QList<QDockWidget *> & _dockwidgets, bool testing) Ligne 2346 C++
      Qt6Widgetsd.dll!QMainWindowLayoutState::restoreState(QDataStream & _stream, const QMainWindowLayoutState & oldState) Ligne 1188 C++
      Qt6Widgetsd.dll!QMainWindowLayout::restoreState(QDataStream & stream) Ligne 2773 C++
      Qt6Widgetsd.dll!QMainWindow::restoreState(const QByteArray & state, int version) Ligne 1291 C++
      displaysetup.exe!main(int argc, char * * argv) Ligne 68 C++

       

      At that point screen is nullptr because QGuiApplication::screenAt() returned nullptr.

      Of course my suggested fix is to replace

      QScreen *screen;
      if (QGuiApplication::primaryScreen()->virtualSiblings().size() > 1)
           screen = QGuiApplication::screenAt(rect.topLeft());
      else
           screen = widget->screen();

       

      by

       

      QScreen *screen = nullptr;
      if (QGuiApplication::primaryScreen()->virtualSiblings().size() > 1)
           screen = QGuiApplication::screenAt(rect.topLeft());
      if(screen == nullptr)
           screen = widget->screen();

       

       

      Attachments

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

        Activity

          People

            anrocha André De La Rocha (Inactive)
            arnaud1602 aaa mmm
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes