itom.uiItem.connect with Python lambda functions

Create issue
Issue #138 resolved
M. Gronle created an issue

Currently, itom.uiItem.connect only holds weak references to the methods or functions in Python, that should be called in the signal is emitted. The reason for this are mainly bounded methods of classes (member methods). If we would increase the reference of these methods as long as the signal/slot connection is established, it would not be possible to properly delete an instance of the class, that contains this method.

However, in the current implementation it is not possible to use a lambda function as slot, since it is directly deleted after the call to the connect method.

Therefore, I suggest that the connect method increases the reference for all unbounded functions (like lambda functions or general functions, that are not bound to a class object) and decreases it if the connection is destroyed. For bounded methods, the current behaviour should be kept.

Comments (1)

  1. M. Gronle reporter

    Fixes a bug in itomUi.disconnect and mainly fixes issue #138: itomUi.connect, actuator.connect and dataIO.connect will now keep a reference of the called function, if it is unbounded (lambda functions, too). Bounded methods will only be reference by means of a weak reference (like before) to avoid cyclic garbage collection stuff.

    → <<cset 042b9c1cb7fc>>

  2. Log in to comment