[PyKDE] underlying c/c++ object has been deleted on postEvent

Ian Monroe ian.monroe at gmail.com
Thu Jun 24 17:47:00 BST 2004

I'm writing a script to display the number of new GMail messages in
the system tray. I'm using GThread because I want to download to occur
in a separate thread. But it crashes with the following error with SIP
Traceback (most recent call last):
File "KNewGmail.py", line 53, in timeEvent
File "KNewGmail.py", line 43, in run
 QApplication.postEvent(self._ug, NewMessageEvent(newMessages()))
AttributeError: sipThis

I updated to SIP 4.0 and recompiled PyQt and PyKDE. I get the same
message, except the AttributeError line has change to:
RuntimeError: underlying C/C++ object has been deleted

Which I understand from Google is due to a null pointer. But that
doesn't make sense.

Hopefully its obvious to someone who knows what their doing. Some
relevant code follows. QTimer calls a TimeObject.timeEvent, so you can
start tracing the code from there.
class NewMessageEvent(QCustomEvent):
     def __init__(self, numberMessages):
             _numberMessages = numberMessages
class UpdateGui(QObject):
     def __init__(self, sys):
             self._sys = sys
     def event(self, e):
class UpdateThread(QThread):
     def __init__(self, ug):
             self._ug = ug
     def run(self):
#the line it raises an error at:
             QApplication.postEvent(self._ug, NewMessageEvent(newMessages()))
class TimeObject(QObject):
     def __init__ (self, sys):
             self._sys = sys
             self._t = UpdateThread(UpdateGui(sys))
     def timeEvent(self):
I'm new to both KDE and Python programming, so the error might be
pretty basic. Or at least there might be other unrelated errors that
python hasn't been able to get to yet. I've posted full source code
to run it also requires:

Ian Monroe

More information about the PyQt mailing list