Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2106

Reg->6.4: QML List properties have duplicated entries

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • None
    • 6.4.0
    • PySide, Shiboken
    • None
    • Python 3.7.9
      PySide 6.4.0
    • Windows
    • bacbf691b3 (pyside/pyside-setup/dev) bacbf691b3 (pyside/tqtc-pyside-setup/dev) 4f9645e9a2 (pyside/pyside-setup/6.4) 73edab21f3 (pyside/pyside-setup/6.3) 4f9645e9a2 (pyside/tqtc-pyside-setup/6.4) 73edab21f3 (pyside/tqtc-pyside-setup/6.3)

    Description

      Since upgrading to PySide 6.4 we have a very strange bug, where all list like properties end up with duplicated elements on the QML side, for example, the python list [1, 2, 3] will appear as [1, 2, 3, 1, 2, 3].

      Minimal code to reproduce the issue: 

      qtBug.py:

      from PySide6.QtCore import QObject, Property
      from PySide6.QtGui import QGuiApplication
      from PySide6.QtQml import QQmlApplicationEngine
      
      
      class Context(QObject):
          @Property(list, constant=True)
          def foo(self):
              return [1, 2, 3]
      
      
      if __name__ == '__main__':
          app = QGuiApplication()
          engine = QQmlApplicationEngine()
          context = Context()
          engine.rootContext().setContextProperty("context", context)
          engine.load("qtBug.qml")
          window = engine.rootObjects()[0]
          window.showNormal()
          app.exec()
      

      qtBug.qml:

      import QtQuick
      
      Window {
          Text {
              text: context.foo.toString()  // Will appear as [1, 2, 3, 1, 2, 3]
          }
      }
      

      This is not just a toString() problem, using the list in a Repeater or checking .length will also show the duplication.
       

      Python 3.10.6
      Qt 6.4.1 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 11.3.0)
      qml: onCompleted: 1,2,3,1,2,3
      QSGThreadedRenderLoop: expose event received for window QQuickWindowQmlImpl(0x556bce2f42f0 exposed, visibility=QWindow::Windowed, flags=QFlags<Qt::WindowType>(Window), title=6.4.1, geometry=0,0 0x0) with invalid geometry: QRect(0,0 0x0) on QScreen(0x556bce256df0, name=DVI-D-0)
      QSGThreadedRenderLoop: expose event received for window QQuickWindowQmlImpl(0x556bce2f42f0 exposed, visibility=QWindow::Windowed, flags=QFlags<Qt::WindowType>(Window), title=6.4.1, geometry=0,0 0x0) with invalid geometry: QRect(0,0 0x0) on QScreen(0x556bce256df0, name=DVI-D-0)
      qt.pyside.libpyside: qtPropertyMetacall ReadProperty #1 QVariantList/"foo" Context(0x558d2cac98e0)
      file:///pyside2106/main.qml:5: TypeError: Cannot read property 'foo' of null
      
      Python 3.10.6
      Qt 6.3.2 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 10.3.1 20210422 (Red Hat 10.3.1-1)) [limited API]
      qml: onCompleted: 1,2,3
      file:///pyside2106/main.qml:5: TypeError: Cannot read property 'foo' of null
      

      Attachments

        1. pyside2106_cpp.zip
          1 kB
        2. pyside2106_diag.diff
          3 kB
        3. pyside2106.zip
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            romanreiner Roman Reiner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes