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

Phil Thompson phil at riverbankcomputing.co.uk
Thu Jun 24 18:18:01 BST 2004

On Thursday 24 June 2004 4:46 pm, Ian Monroe wrote:
> 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

In all of your __init__ functions above you are forgetting to call the 
super-class __init__ function.


More information about the PyQt mailing list