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

Unloading TableView headers via Loaders causes crash

    XMLWordPrintable

Details

    • All
    • e5c031c1a (dev), d594c023b (6.7), 0e4569577 (6.6), f919bffb7 (tqtc/lts-6.5)

    Description

      I used a Loader to show or hide a vertical header for a TableView and noticed in the qml tests that it sometimes crashes. I tried to reproduce it with the default example from the VerticalHeaderView documentation, but wrapped the HeaderViews with a Loader.

      When the Loader unloads the component the application crashes.

      Use the buttons in the example code to toggle the active property of the Loader.

       

      import QtQuick
      import QtQuick.Controls
      import Qt.labs.qmlmodels
      
      ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("HeaderView")
      
        Item {
          anchors.fill: parent
      
      
          Loader {
            id: horizontalHeaderLoader
            anchors {
              top: parent.top
              left: tableView.left
            }
      
            sourceComponent: HorizontalHeaderView {
              id: horizontalHeader
              syncView: tableView
              clip: true
            }
          }
      
          Loader {
            id: verticalHeaderLoader
            anchors {
              top: tableView.top
              left: parent.left
            }
      
            sourceComponent: VerticalHeaderView {
              syncView: tableView
              clip: true
            }
          }
      
          TableView {
            id: tableView
            anchors.left: verticalHeaderLoader.active ? verticalHeaderLoader.right : parent.left
            anchors.top: horizontalHeaderLoader.active ? horizontalHeaderLoader.bottom : parent.top
            anchors.right: parent.right
            anchors.bottom: parent.bottom
            clip: true
      
            columnSpacing: 1
            rowSpacing: 1
      
            model: TableModel {
              TableModelColumn { display: "name" }
              TableModelColumn { display: "color" }
      
              rows: [
                {
                  "name": "cat",
                  "color": "black"
                },
                {
                  "name": "dog",
                  "color": "brown"
                },
                {
                  "name": "bird",
                  "color": "white"
                }
              ]
            }
      
            delegate: Rectangle {
              implicitWidth: 100
              implicitHeight: 20
              color: palette.base
              Label {
                text: display
              }
            }
          }
        }
      
        Button {
          text: "VHeader Show/hide"
          onClicked: {
            verticalHeaderLoader.active = !verticalHeaderLoader.active
            print(verticalHeaderLoader.active)
          }
          y: 200
        }
      
        Button {
          text: "HHeader Show/hide"
          onClicked: {
            horizontalHeaderLoader.active = !horizontalHeaderLoader.active
            print(horizontalHeaderLoader.active)
          }
          x: 150
          y: 200
        }
      }
       

       

       

      Attachments

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

        Activity

          People

            richard Richard Moe Gustavsen
            voodoo66 Voodoo Master
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes