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

"segmentation fault" is caused by connecting to a slot after disconnecting a nonexistent connection

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.15.15
    • 5.15.3, 6.2.1
    • PySide
    • None
    • All
    • 360ef4e884db56e3cd228593bbc562727fbd41cd (pyside/pyside-setup/dev) 105490ccd31ae2eed54c5512b20467a1d2f88a01 (pyside/pyside-setup/6.2) 9dcc454ee166806a5a20516021f82f619bc39b99 (pyside/tqtc-pyside-setup/5.15)

    Description

      If you connect to a slot (a method with decorate Slot) after disconnecting a non-existent connection to the same slot it causes "segmentation fault".

       

      from PySide6.QtCore import QCoreApplication, QObject, QTimer, Signal, Slot
      
      
      class Foo(QObject):
          foo_signal = Signal()
      
          def bar(self):
              pass
      
          @Slot()
          def baz(self):
              pass
      
          def test_without_slot(self):
              try:
                  self.foo_signal.disconnect(self.bar)
              except RuntimeError as e:
                  print(e)
              self.foo_signal.connect(self.bar)
              print("test_without_slot: after connect")
      
          def test_with_slot(self):
              try:
                  self.foo_signal.disconnect(self.baz)
              except RuntimeError as e:
                  print(e)
              self.foo_signal.connect(self.baz)
              print("test_with_slot: after connect")
      
      
      if __name__ == "__main__":
          app = QCoreApplication()
      
          foo = Foo()
      
          QTimer.singleShot(1000, foo.test_without_slot)
      
          QTimer.singleShot(2000, foo.test_with_slot)
      
          QTimer.singleShot(5000, app.quit)
      
          app.exec()
      
      Failed to disconnect signal foo_signal().
      test_without_slot: after connect
      Failed to disconnect signal foo_signal().
      [1]    89466 segmentation fault (core dumped)  python main.py
      

      Attachments

        1. pyside1715_diag.diff
          10 kB
        2. pyside1715_log.txt
          3 kB
        3. pyside1715_stack.txt
          36 kB
        4. pyside1715.py
          0.9 kB
        5. PYSIDE1715.py
          0.9 kB
        For Gerrit Dashboard: PYSIDE-1715
        # Subject Branch Project Status CR V

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            eyllanesc Edwin Christian Yllanes Cucho
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: