Menu

#311 Taurus4 is not back-comp in the connection of old-style signals.

I['Jul16', '']
resolved
bug
2016-07-15
2016-07-07
No

Since Taurus4 is not force to use PyQT API 2 yet, a back-comp layer sould be offered to be compatible with non adapted external applications, e.g. Sardana.

You can see this behaviour in the SharedDataManager, and can be reproduce with this code:

from taurus.qt.qtcore.communication import SharedDataManager
from taurus.external.qt.QtCore import QObject, pyqtSlot, pyqtSignal, QString, SIGNAL

class SignalTest(QObject):

    activated = pyqtSignal([int], ["QString"])

    def new_connect_activated(self):
        # The PyQt4 documentation will define what the default overload is.
        # In this case it is the overload with the single integer argument.
        self.activated.connect(self.handle_int)

        # For non-default overloads we have to specify which we want to
        # connect.  In this case the one with the single string argument.
        # (Note that we could also explicitly specify the default if we
        # wanted to.)
        self.activated["QString"].connect(self.handle_string)

    def old_connect_activated(self):
        self.connect(self, SIGNAL("foo(int)"), self.old_handle_int)

    def handle_int(self, data):
        print "[NEW] activated signal passed integer", data

    def old_handle_int(self, data):
        print "[OLD] activated signal passed integer", data

    def handle_string(self, text):
        print "activated signal passed QString", text

    def signalEmiter(self, value):
        self.activated.emit(value)

    def oldSignalEmiter(self, value):
        self.emit(SIGNAL("foo(int)"), value)

    def readerNS(self):
        print "This is the reader [NEW-style]"

    def readerOS(self):
        print "This is the reader [OLD-style]"

sdm = SharedDataManager(None)
s = SignalTest()
s.new_connect_activated()
s.old_connect_activated()
sdm.connectWriter("test1", s, "foo(int)")
sdm.connectWriter("test2", s, "activated")
sdm.connectReader("test1", s.readerOS)
sdm.connectReader("test2", s.readerNS)

s.signalEmiter(1)
# it will raise an AttributeError: 'SignalTest' object has no attribute 'foo
s.oldSignalEmiter(2)

Discussion

  • Carlos Falcon

    Carlos Falcon - 2016-07-07
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -Since Taurus4 is not force to use PyQT API 2 yet, a back-comp layer sould be offer to be compatible with non adapted external applications, e.g. Sardana. 
    +Since Taurus4 is not force to use PyQT API 2 yet, a back-comp layer sould be offered to be compatible with non adapted external applications, e.g. Sardana. 
    
     You can see this behaviour in the SharedDataManager, and can be reproduce with this code:
    
     
  • Carlos Pascual

    Carlos Pascual - 2016-07-15
    • status: waiting --> resolved
    • assigned_to: Carlos Pascual
     
  • Carlos Pascual

    Carlos Pascual - 2016-07-15

    Essentially the problem is that the communication module connects signals from arbitrary widgets (which may themselves be programmed with old-style signals). This needs to be supported as well..

    The same issue occurs with the AbstractSwitcher class.

    A patch was sent to the devel list and applied to the develop branch

     
  • Carlos Pascual

    Carlos Pascual - 2016-07-15
    • Labels: old-style signal --> taurus4, old-style signal
    • Category: taurus4 --> Jul16,