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

Crash with native QComboBox in refreshing QWidget

    XMLWordPrintable

Details

    • macOS
    • 03d62322b (dev), fa3b609bd (6.5), c462d33d3 (6.6)

    Description

      When using a native QComboBox on macOS, Qt will simulate a mouse click on the original button per the comment in qcombobox.cpp:

      // The Cocoa popup will swallow any mouse release event.
      // We need to fake one here to un-press the button.

      If the selection of a value in the combobox triggers a refresh of the Widgets, effectively removing the source of the native combobox, this can lead to a crash because the original Widget has been deleted already:

       

      QMouseEvent mouseReleased(QEvent::MouseButtonRelease,
                                q->pos(),
                                q->mapToGlobal(QPoint(0, 0)),
                                Qt::LeftButton,
                                Qt::MouseButtons(Qt::LeftButton),
                                {});
      [..]
      QPoint result = data->crect.topLeft(); // data is NULL already
      [..]
      { return QPoint(x1, y1); }             // inline function will crash because x1 does not exist
      

       

      In the application I ran into this a selection of a combobox triggers a refresh and calls widget->deleteLater(); on the parent widget, which works most of the time but in some cases the change of the combobox value happens before the mouseRelease event can be simulated.

      If the code were to check if the originating Widget actually still exists and is a valid widget (QWidgetData is NULL) before simulating the mouse event, the crash could be avoided.

      Attachments

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

        Activity

          People

            vhilshei Volker Hilsheimer
            patthemav Patrick Heyer
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes