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

Crash when sizing box layout with gap in inserted widgets

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4.2
    • Widgets: Layout
    • None

    Description

      Reproducer script attached.

      Essentially, when displaying a QBoxLayout that has had two widgets inserted, using the following two calls:

      layout.insertWidget(0, label0);
      layout.insertWidget(2, label2);

      there is an access violation memory error (0xc0000005) when attempting to calculate the layout geometry on show.

      I don't know if this is supposed to be supported. The behaviour when calling `insertWidget` with a positive index outside the list range is not documented. I can say that on Qt5.15, this worked, because the second call above would end up appending to the layout (at position 1), rather than inserting at position 2. This meant the layout had two sequential entries.

      I can work around this on our app. But I think this behaviour should probably either be fixed or explicitly documented as unsupported.

      Relevant part of stack trace:

      Unhandled exception at 0x00007FF9CDCCAC80 (Qt6Widgets.dll) in app.exe.14916.dmp: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
      
      Qt6Widgets.dll!QLayout::activateRecursiveHelper(QLayoutItem * item) Line 952
      Qt6Widgets.dll!QLayout::activateRecursiveHelper(QLayoutItem * item) Line 957
      Qt6Widgets.dll!QLayout::activate() Line 1012
      Qt6Widgets.dll!QWidgetPrivate::setVisible(bool visible) Line 8283

      Found in Qt 6.4.2, not tested on more recent versions but I can't see any cases for this.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            arthurgw Arthur Gordon-Wright
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes