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

FileDialog accesses role of outside model

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.12.7
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      macOS 10.15.4
      Qt 5.12.7
    • Platform/s:
      macOS

      Description

      Native FileDialog (macos, QtQuick.Dialogs 1.3) accesses roles of "outside" model . This happens only when FileDialog component is created inside delegate instantiated by a model that has 1 role. As soon as this model has 2 or more roles, everything works fine.

      I found this strange behaviour during development of my own model based on QAbstractListModel, but i was able to simplify it by using simple ListModel in qml.

      To demonstrate this behaviour:
      1) run

      qmlscene main.qml
      

      2) open file dialog by clicking on a button
      3) browse via different directories and choose some file (this is important ! seems like more directories you visit, more errors you get)
      4) accept the dialog
      5) you see bunch of errors as function cannot be converted into text. Errors themselves are not important. Important is that errors are thrown because FileDialog tries to access role from myModel.
      If you used your own model based on QAbstractListModel, you would see how data() is called.

      qml code to reproduce:

      //main.qml
      import QtQuick 2.12
      import QtQuick.Controls 2.12
      import QtQuick.Dialogs 1.3
      
      Item {
          width: 200
          height: 200
      
          ListModel {
              id: myModel
              //bug happens when model has only 1 role
              //everything works fine when 2 roles are used
              ListElement {
                  cusomRole: function() {}
                  //cusomRole2: function() {}
              }
          }
      
          Column {
              spacing: 10
              Repeater {
                  model: myModel
      
                  delegate: Item {
                      width: 100
                      height: 100
      
                      Button {
                          text: "open file dialog"
                          onClicked: {
                              console.log("call open")
                              fileDialog.open()
                          }
                      }
      
                      FileDialog {
                          id: fileDialog
                          folder: shortcuts.documents
                          onAccepted: {
                              console.log("accepted")
                          }
                      }
                  }
              }
          }
      }
      

      console output:

      ~/dev/bugs/file-dialog$ ~/Qt/5.12.7/clang_64/bin/qmlscene main.qml
      qml: call open
      Model size of -163 is less than 0
      Model size of -17 is less than 0
      qml: accepted
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:383:29: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:383:29: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:360:29: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:360:29: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:360:29: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:383:29: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:109:13: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:383:29: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:383:29: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:360:29: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:360:29: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:360:29: Unable to assign a function to a property of any type other than var.
      file:///Users/martin/Qt/5.12.7/clang_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:383:29: Unable to assign a function to a property of any type other than var.
      

        Attachments

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

          Activity

            People

            Assignee:
            dfaure_kdab David Faure
            Reporter:
            keresan Martin Mich
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes