[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
3.8:
Traceback (most recent call last):
File "KNewGmail.py", line 53, in timeEvent
self._t.run()
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):
self._sys.setNum(e._numberMessages)
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):
self._t.run()
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
at:
http://monroe.nu/projects/KNewGmail_broken.py
to run it also requires:
http://monore.nu/projects/KNewGmail/gmail.py
Thanks,
Ian Monroe
More information about the PyQt
mailing list