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

Memory leak / reference counting error with destroyed objects from qmlRegisterType

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: 5.12.6, 5.15.1
    • Fix Version/s: None
    • Component/s: PySide, Shiboken
    • Labels:
      None
    • Platform/s:
      Windows

      Description

      When a Python QML type registered with qmlRegisterType gets destroyed in the QML context (e.g. by using a loader), the Python object is not getting garbage collected.

      I have attached a minimal example. To reproduce hit the "Toggle" button three times. At this point there are two objects in the WeakSet, but one of these objects were already deleted at the second toggle click (destroyed signal was emitted).

      You can see in the output from objgraph, that the Python object has only 2 strong references in the current frame (and none other in Python), but the refcount is 5. So there has to be some some ref counting errors in C++ / shiboken.

      Tested on Windows, but other platforms are probably affected, too.

        Attachments

        1. main.py
          1 kB
        2. type.qml
          0.1 kB
        3. view.qml
          0.4 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            crmaurei Cristian Maureira-Fredes
            Reporter:
            schlamar schlamar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes