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

Mouse messages for QDockWidget are incorrectly cast to QMainWindow causing a crash

    XMLWordPrintable

Details

    • Windows
    • 81ed068a5 (dev), ccbf28a56 (6.9), 39ba5ed46 (6.8), 702acf9bf (tqtc/lts-6.5)

    Description

      My app uses multiple floating QDockWidgets.  When they are combined, a crash occurs.

      I will walk through the stack since I am unable to create a repro case.

      See the video for how crash is reproduced.

      Here is the complete stack

      It is a mouse event

      Farther down we sent event to the receiver

      The receiver is QDockWidgetGroupWindow

       

      QDockWidgetGroupWindow treats it as a windowEvent

      Which is handled by QMainWindowLayoutSeparatorHelper as a HoverMove and adjustCursor is called

      adjustCursor call findSeparator

      Which calls toolBarAreaLayout

       

       

      At this point, you can see that mainWindow is derived from QDockWidgetGroupWindow

      Now we cast the parentWidget to QMainWindow, when it is not a QMainWindow

              auto mainWindow = static_cast<QMainWindow>(parentWidget());

      After this, it crashes.  'd' is not valid after this cast

      QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow)

      {     return QMainWindowPrivate::mainWindowLayout(mainWindow); }

       

          static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow)
         

      {         return mainWindow ? mainWindow->d_func()->layout.data() : static_cast<QMainWindowLayout *>(nullptr);     }

       

       

       

       

       

       

      Attachments

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

        Activity

          People

            vestbo Tor Arne Vestbø
            doug_rogers Doug Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes