[PyKDE] Quitting invokes crash handler

Jim Bublitz jbublitz at nwinternet.com
Fri Aug 30 22:01:24 BST 2002


On 30-Aug-02 Gordon Tyler wrote:
> Jim Bublitz wrote:
>> On 29-Aug-02 Gordon Tyler wrote:
 
>>>Frederick Polgardy Jr wrote:

>>>>   a.connect(a, SIGNAL("lastWindowClosed()"), w.fileQuit)

>>>I would write the above line like this (wordwrapped for
>>>reading):
 
>>>     a.connect(a, SIGNAL("lastWindowClosed()"),
>>>         KApplication.kApplication(), SLOT("quit()"))
 
>> The original line is both correct and different in function from
>> your suggested rewrite. 'w.fileQuit' might actually do something
>> useful (like save files, cleanup, etc) in a real program.
 
> But wouldn't that connection be referring to a slot on an
> instance that no longer exists? w is the only window, when it
> is closed, the lastWindowClosed signal is fired, but the
> instance that it connects to is gone. Or am I misunderstanding
> the lifecycle of the w instance?

I see your point and don't actually know the answer - that's
another reason I'd opt for the 'queryClose' and 'queryExit'
functions that are part of the KMainWindow class.

I have seen the idiom above used in a number of places and it
generally seems to work (it works when PyKDE is fixed by adding the
KApplication dtor referenced in another post). It depends a lot on
what 'lastWindowClosed' actually means (I haven't looked) and also
on whether 'w' being closed (or removed from the app's widget
list) == 'w' being destroyed - the two aren't necessarily the same. 
For example, 'dialog closed' != 'dialog destroyed'.

Jim




More information about the PyQt mailing list