Catch a windows exit?

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE
Locked
HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Catch a windows exit?

Post by HPW »

When I close the window of 'tower of hanoi' demo, I get a error 'invalid command name ".hw.can" '. Is their a way to catch the closing message properly and make a clean exit?
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

This should only occur, if you close the window before Hanoi has finished (it's a timing situation, expensive to code around). If it occurs after Hanoi finished then it's a bug, but I can't reproduce it.

Also, I replaced v.7.0.1 at 11:36pm 2002-10-24 Pacific Standard Time and I think you (?) downloaded 7.0.1 just before it. I replaced 7.0.1 because of a last minute newlisp_manual.html change for latest pop3.lsp.

Lutz

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

>This should only occur, if you close the window before Hanoi has finished (it's a timing situation, expensive to code around).

That's what I mean. Exiting during execution. I only want to know if it is possible to code around!

Thanks for the download-hint on 7.001.
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

newLISP is pushing graphics operations to the Tcl/Tk frontend. The Tcp/Ip listener port in the Tcl/Tk frontend is event driven. It receives Tcl/Tk commands and executes them. Now you are closing the window and the graphics command draws in an nonexisting window, which is called .hw.can (the hanoi window canvas). In TK widgets are treated like commands, which can execute stuff on themselves, kind of an OO approach.

One could code around it, checking the existence of .hw.can before each drawing command with "winfo exists .hw.can" which returns 1 or 0 depending on existence. You would do this in the "(make-disk ...)" function:

(if (= (tk "winfo exists .hw.can") "1")
(tk ".hw.can create rectangle " x " " y " " x1 " " y1 " -fill red -tag " "disk" disk))

Lutz

Locked