Skip to content

Commit 78678e8

Browse files
committed
WIP: Fix pyside.Signal.connect complex objects
resolves #7 Signed-off-by: Nir Izraeli <[email protected]>
1 parent 480bd2e commit 78678e8

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

idasix.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,47 @@ class action_handler_t_objprotector(action_handler_t_object):
9797

9898
@staticmethod
9999
def qtsignalslot():
100-
"""While pre-6.8 qt4 library pyside exposted `Qtcore.Signal` and
100+
"""While pre-6.8 qt4 library pyside exposed `Qtcore.Signal` and
101101
`QtCore.Slot`, new pyqt library exposes those same methods as
102102
`QtCore.pyqtSignal` and `QtCore.pyqtSlot`. This fix makes sure
103-
`Qtcore.Signal` and `QtCore.Slot` are always available"""
103+
`Qtcore.Signal` and `QtCore.Slot` are always available.
104+
105+
While pyqt4 and pyside are equivalent, they are different implementations.
106+
Therefore some slight variations and bugs may manifest in one but not the
107+
other. An example of this is pyside's buggy handling of callback closures.
108+
109+
"""
104110
if IDA_SDK_VERSION >= 690:
105111
QtCore.Signal = QtCore.pyqtSignal
106112
QtCore.Slot = QtCore.pyqtSlot
107113
elif IDA_SDK_VERSION < 690:
114+
115+
116+
class pysideSignal_wrapper(QtCore.QObject):
117+
118+
pysideSignal_cls = QtCore.Signal
119+
pysideSignalInstance = QtCore.Signal(dict)
120+
121+
def __init__(self, *args, **kwargs):
122+
self.pysideSignal_obj = self.pysideSignal_cls(*args, **kwargs)
123+
124+
def __getattr__(self, attr):
125+
print(self, self.pysideSignalInstance, attr)
126+
return getattr(self.pysideSignal_obj, attr)
127+
128+
def connect(self, callback, *w_args, **w_kwargs):
129+
print(self, callback)
130+
wrapped_callback = lambda *args, **kwargs: callback(*args, **kwargs)
131+
return self.pysideSignal_obj.connect(wrapped_callback, *w_args, **w_kwargs)
132+
133+
QtCore.Signal = pysideSignal_wrapper
134+
print(pysideSignal_wrapper.pysideSignalInstance, type(pysideSignal_wrapper.pysideSignalInstance))
135+
i = pysideSignal_wrapper()
136+
print(i, type(i))
137+
print(i.connect)
138+
i.connect = None
108139
pass
109140

110-
111141
Fix.packagespath()
112142
Fix.actionhandlerobject()
113143
Fix.qtsignalslot()

0 commit comments

Comments
 (0)