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

Using signals derived from Mixin breaks slots in derived classes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Fixed
    • Affects Version/s: dev
    • Fix Version/s: dev
    • Component/s: PySide
    • Labels:
      None

      Description

      There is an issue in PySide2/Qt5 when using signals derived from mixin.

      For example, the following code doesn't print "emit2". After calling mySignal.connect(), mySlot is never called.

      import PySide2.QtCore as QtCore
      
      class Mixin(object):
          mySignal = QtCore.Signal()
          def __init__(self, *args, **kwargs):
              super(Mixin,self).__init__(*args, **kwargs)
              
      class Derived(Mixin, QtCore.QObject):
          echoSignal = QtCore.Signal(str)
          
          def __init__(self):
              super(Derived,self).__init__()
              self.echoSignal.connect(self.mySlot)
          
          def mySlot(self, v):
              print v + ' -> mySlot' 
       
      def nopSlot():
          pass
       
      obj = Derived()
      obj.echoSignal.emit('emit1')
      obj.mySignal.connect(nopSlot)  # This line breaks mySlot..
      obj.echoSignal.emit('emit2')
      

      I suspect that this is caused by a change to sort slots and signals in dynamicqmetaobject.cpp. Probably someone is still using index from AddMethod()?

        Attachments

        1. MAYA-76654_stripped.zip
          1 kB
        2. metaobjdump_170127.zip
          2 kB
        3. pyside315.py
          0.7 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              ctismer Christian Tismer
              Reporter:
              mingxiang Mingxiang Xu
            • Votes:
              2 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes