Login  Register

Re: System Windows not closing on using #close

Posted by Ben Coman on Aug 08, 2015; 3:59pm
URL: https://forum.world.st/System-Windows-not-closing-on-using-close-tp4841568p4841702.html

If you put a "self halt" at the top of IndexInterface>>#delete, then
after opening the app, on one of the buttons (e.g. Browse Files) bring
up its halos and click the Spanner/Debug icon, then "Inspect owner
chain", and you will see a SystemWindow within a SystemWindow. Now
click that button and the debugger will show that boxWindow is the
inner SystemWindow, so when you close that you leave the outer
SystemWindow.

Actually the nested SystemWindows are apparent from the
close-minimise-maximise icons in the top-left of each.  This seems
wrong. Putting a "self halt" in IndexInterface>>#initialize and
stepping into "boxWindow openInWindowLabeled: 'searchQuick' " shows
how you end up with nested SystemWindows.  As you trace through,
notice that SystemWindow>>openInWindowLabeled:inWorld: returns the
window it creates, so maybe you instead want "boxWindow := box
openInWindowLabeled: 'searchQuick' "

A few other things:
* SystemWindow>>close simply calls "self delete" so there seems no
need to call both, just #delete.
* From the debugger evaluating "boxWindow" and "boxWindow window"
return the identical object (per identical number in brackets), so
there seems no need to delete both.

cheers -ben

On Sat, Aug 8, 2015 at 1:47 PM, Jigyasa Grover
<[hidden email]> wrote:

> Hi
> I am using SystemWindow to open a Morph in my application searchQuick. (
> https://github.com/jig08/sQuick_new )
> On clicking a button, a new screen opens up but the prev window fails to
> close, though I have tried using #close methods.
>
> The code snippets are as:
>
> ------------------------------------------------------------------------------------------------------------------
> IndexInterface>>#initialize
> . . . . . .
>       boxWindow := SystemWindow new.
>       box position: 150@0.
>       boxWindow addMorph: box.
>       boxWindow extent: World extent.
>       boxWindow openInWindowLabeled: 'searchQuick'.
>       boxWindow fullscreen.
>       boxWindow color: Color black.
> . . . . . . .
>
> browseBtn on: #click send: #value to: [self boxWindow window close.
> IndexInterface delete. BrowseFiles open].
>
> -------------------------------------------------------------------------------------------------------------------
> IndexInterface>>#delete
> box isNil ifFalse: [  self boxWindow window close.
>                                          self boxWindow window delete .
>                                          self boxWindow close.
>                                          box window close .
>                                          self boxWindow delete.
>                                          box delete.].
> box := nil.
> self boxWindow window close.
> self boxWindow window delete .
> self boxWindow close.
> self boxWindow delete.
> boxWindow := nil.
>
> -------------------------------------------------------------------------------------------------------------------
>
> Help appreciated.
>
> Regards
> Jigyasa

ScreenShot-SearchQuick.png (168K) Download Attachment