Catch a windows exit?

Started by HPW, October 24, 2002, 10:42:58 PM

Previous topic - Next topic

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

#1
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

#2
>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

#3
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