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

Calls to QWidget.parent() invalidate non-owning Python objects

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4: Low
    • 6.8.0
    • 6.5.3, 6.7.0
    • PySide, Shiboken
    • None
    • Linux/X11, Windows
    • ffd12d645 (dev)

    Description

      When a QWidget that has been inserted in a QTabWidget gets its parent() (or parentWidget()) method called, non-owning Python objects [that are wrapping Qt objects that are present in the widget's hierarchy] are wrongly invalidated.

      The issue manifests when the widget is inserted in a QTabWidget, but not with other organizer widgets such as QSplitter. The intermediate QStackedWidget in QTabWidget may be contributing to the issue.

      In the following snippet, assume that a "menu" object exists in a menu bar inside the widget (self) which lives in a tab in a QTabWidget:

      menu = self.findChild(QtCore.QObject, 'menu')
      
      print(Shiboken.isValid(menu))  # Prints "True"
      self.parent()                  # Wrongly invalidates `menu`
      print(Shiboken.isValid(menu))  # Prints "False"

      An example Qt application (test_app.py) has been attached to easily reproduce the unexpected behavior.

      Attachments

        1. pyside2711.py
          2 kB
          Friedemann Kleint
        2. test_app.py
          2 kB
          Christian Aguilera
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            christian.aguilera.foundry Christian Aguilera
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes