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

List:       pykde
Subject:    Re: [PyQt] Signals arriving after proxy slots deleted
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2012-04-16 12:00:20
Message-ID: 1d9297ffe66fc2f03426a932958bd996 () localhost
[Download RAW message or body]

On Mon, 16 Apr 2012 10:59:20 +0100, Andrew Suffield
<asuffield@suffields.me.uk> wrote:
> Pretty sure it's a pyqt bug, in deleteSlotProxies:
> 
>             if (QThread::currentThread() == up->thread())
>                 delete up;
>             else
>                 up->deleteLater();
> 
> http://qt-project.org/doc/qt-4.8/qobject.html#dtor.QObject
> 
> "Warning: Deleting a QObject while pending events are waiting to be
>  delivered can cause a crash. [...] Use deleteLater() instead, which
>  will cause the event loop to delete the object after all pending
>  events have been delivered to it."

But the bit you edited out said...

"You must not delete the QObject directly *if it exists in a different
thread than the one currently executing*."

...my emphasis.

> Qt makes no effort to clean out pending events when an object is
> deleted.

That's not what the documentation says...

"any pending posted events for the object are removed from the event
queue"

> deleteSlotProxies has no reason to believe that pending
> events are not waiting to be delivered - and in the case I have, there
> are pending events. It should use deleteLater unconditionally.
> 
> In fact I would suggest that it is probably always wrong for pyqt to
> delete a QObject rather than deleteLater, since it has no idea what
> the application code may have in the event queue.

Can you make the change you are suggesting and see if it makes a
difference? If it fixes the problem then it doesn't matter what the docs
say.

Phil
_______________________________________________
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