[PyKDE] Re: really wierd qthread + emit issue

Lukáš Lalinský lalinsky at gmail.com
Wed Nov 22 08:09:59 GMT 2006


Matt Chambers  wrote / napísal(a):
> Using PyQt 4.0 and Qt 4.1.  I'm emitting a single from a QThread with a
> single argument.   About 50% of the time when  I catch
> the signal and execute the slot function, the argument is a QMutex
> object, not the argument I emitted with the signal.
> 
> Here is my threads run() function.
> 
[...]
> 
> Notice I'm emitting the signal with a cuejob.CueJob object, but from the
> slot, when I print the first argument, I get:
> <PyQt4.QtCore.QMutex object at 0xf6b0b22c>

There are two problems with the code:

1. Don't use "short-circuit" signals for communication between threads. The slot
will be called from the same thread, not via the queued connection from the main
thread, which is probably what you want. Use
QtCore.SIGNAL("parsingComplete(PyObject*)") instead.

2. Keep references to the emit arguments, otherwise they will get deleted and
replaced with a different objects that reuse the same memory block.

-Lukáš




More information about the PyQt mailing list