[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] event() gets called but C++ object already deleted
From:       Wilbert Berendsen <wbsoft () xs4all ! nl>
Date:       2011-05-25 7:37:44
Message-ID: 201105250937.45173.wbsoft () xs4all ! nl
[Download RAW message or body]

Hi,

I have a PyQt4 subclass of a QToolButton that implements event() (to show 
custom tooltips as they need to appear):

    def event(self, ev):
        if ev.type() == QEvent.ToolTip:
            # handle it.....
            return True
        return super(Button, self).event(ev)

The problem is that on Windows, while the application is closing itself, 
event() gets called (with a QActionEvent) while the super() call results in a 
RuntimeError: underlying C/C++ object has been deleted.

Changing the super() line into 'return QToolButton.event(self, ev)' does not 
help.

Is it a correct workaround to simply wrap the return super... line in a 
try/except clause? Or is there a better way to prevent this?

Can I prevent that event() is called while the c++ object is not living 
anyway?

with best regards,
Wilbert Berendsen

-- 
http://www.wilbertberendsen.nl/
"You must be the change you wish to see in the world."
        -- Mahatma Gandhi
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic