[PyKDE] ANN: SIP/PyQt v3.5 & QScintilla v0.3 Released

Phil Thompson phil at river-bank.demon.co.uk
Fri Dec 13 16:49:01 GMT 2002


On Friday 13 December 2002 2:53 pm, Michael Lauer wrote:
> Am Fre, 2002-12-13 um 02.11 schrieb Phil Thompson:
> > > Could you give me a hint how to wrap QCopEnvelope? I need
> > > it for our project since calling /opt/QtPalmtop/bin/qcop is way to
> > > slow.
>
> [...]
>
> I have wrapped QCopEnvelope with success.
>
> > There shouldn't be any problem implementing the << operator by providing
> > an __lshift__ method in the same way that __iadd__ is implemented for
> > QSemaphore.
>
> I overlooked that QCopEnvelope is derived from QDataStream. QDataStream
> doesn't implement the << and >> operators, but provides writeBytes(),
> which should be sufficient... if there wasn't a problem concerning the
> data bytes.
>
> One example: Sending a QCOP message without parameters works very good,
> e.g. the following code make an hourglass appear on the taskbar
> ("del e" is neccessary, because the QCopEnvelope sends its message in
> the C++ destructor):
>
> e = qtpe.QCopEnvelope( "QPE/System", "busy()" )
> del e
>
> Very good. Sending a QCOP message with parameters also works fine, when
> the receiver is PyQt, e.g.
>
> e = qtpe.QCopEnvelope( "QPE/Application/elan", "message()" )
> e.writeBytes( "HelloWorld!" )
> del e
>
> works also as expected.
>
> Now the case which does not function: The following code _should_ make a
> string appear on the TaskBar (it's basically the same what
> Global::statusMessage() does):
>
> e = qtpe.QCopEnvelope( "QPE/TaskBar", "message(QString)" )
> e.writeBytes( "HelloWorld!" )
> del e
>
> But the only thing I get is garbage on the taskbar. The message seems to
> be received, but somehow the data is not "marshalled" or interpretated
> correctly. Or could it be possible (since the message is sent inside the
> destructor) that the corresponding char* has been deleted or overwritten
> before it is accessed by the QCopEnvelope?

Shouldn't the following prove if it's being deleted/overwritten?

s = "Hello World!"
e = qtpe.QCopEnvelope( "QPE/TaskBar", "message(QString)" )
e.writeBytes(s)
del e

Phil




More information about the PyQt mailing list