[PyKDE] PyQt4: PyObject in SIGNAL
phil at riverbankcomputing.co.uk
Tue Dec 5 12:54:57 GMT 2006
> Phil Thompson wrote:
>>> But this still does not answer my question: what does "PyObject" means
>>> the signature of a signal?
>> This was my original email:
> In this mail, you said that SIGNAL("foo(PyObject*)") and SIGNAL("foo") are
> same. In my application, the latter does work, but the former was causing
> random crash in the code (the object that arrived in the slot was "wrong",
> had a different id() than the object that was being emitted, and basically
> caused a core dump as soon as you accessed it somehow).
> I guess there is a bug somewhere. Do you need a repro recipe?
No thanks. It's now fixed but I haven't committed the change yet.
>> Also, PyQt doesn't do anything special with the reference counts of
>> PyObject *
>> arguments, so you have to make sure that the objects stay alive until
>> all the
>> slots in other threads have been run.
> In the crash experimented above, there were no threads involved. There was
> QProcess, but I don't think that changes things much.
>> It might be possible to wrap a PyObject * in a C++ class that can be
>> passed to
>> qRegisterMetaType() and that handles the reference count. I think that
>> mean that you could forget the signal arguments after calling emit(). I
>> to think about that a bit more.
> I think something along these lines would be great.
Also done but not yet committed. The only difference is that it's now
"PyQt_PyObject" instead of "PyObject *".
More information about the PyQt