[Idle-dev] Slow close?

Stephen M. Gava elguavas@users.sourceforge.net
26 Feb 2002 11:01:45 +1100


Guido van Rossum wrote:
> I think this is an attempt to make sure that when the dialog "do you
> want to save ... before closing" is displayed, the right window is on
> top.  That dialog is presented (if necessary) by maybesave().  I'm
> sure you can figure out a better way to ensure this.  To test this
> behavior, you should create a whole bunch of unsaved windows (but
> saved to files so you can tell them apart), reorder them randomly,
> iconify a few, and then hit control-Q.  This should pop up the windows
> to match the "do you want to save" dialogs.

Turns out that it is the call to tkraise() that's causing the problem,
maybe something to do with the window manager barfing when being asked
to move a window to the top of the stack that is already on top? I moved
the 'make sure the relevant window is displayed' code into maybesave()
since it only applies if we have a window we need a save query on, then
I made sure we only deiconify() if required. I found a q&d way to make
the tkraise() not choke things by simply lowering the window first so
that the lift() always does something, ending up with this:

def maybesave(self):
    if self.io:
        if self.top.state()!='normal': 
            self.top.deiconify()
        self.top.lower()
        self.top.lift()
        return self.io.maybesave()

This works well under X when tested as you suggested, but I haven't
tested it on windows yet. Also I will see if I can find a way to test
whether the desired window is already at the top of the stack, so that I
can do away with that q&d lower(), if possible.

Stephen.
-- 
Stephen M. Gava  <elguavas@users.sourceforge.net>
IDLEfork ( http://idlefork.sourceforge.net )  " just like IDLE, only
crunchy "