This is a multi-part message in MIME format. --===============1213700533== Content-Type: multipart/alternative; boundary="------------080802050109020703010509" This is a multi-part message in MIME format. --------------080802050109020703010509 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Luk=C3=A1=C5=A1 Lalinsk=C3=BD wrote: > Matt Chambers wrote / nap=C3=ADsal(a): > =20 >> 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. >> >> =20 > [...] > =20 >> Notice I'm emitting the signal with a cuejob.CueJob object, but from t= he >> slot, when I print the first argument, I get: >> >> =20 > > 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 delet= ed and > replaced with a different objects that reuse the same memory block. > > =20 Fixing those two things worked thanks! --------------080802050109020703010509 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Luk=C3=A1=C5=A1 Lalinsk=C3=BD wrote:
Matt Chambers  wrote / nap=C3=ADsal(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 ob=
ject, 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. T=
he slot
will be called from the same thread, not via the queued connection from t=
he 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.

  
Fixing those two things worked thanks!


--------------080802050109020703010509-- --===============1213700533== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ PyKDE mailing list PyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde --===============1213700533==--