rabbibotton / clog

CLOG - The Common Lisp Omnificent GUI
Other
1.53k stars 106 forks source link

Tutorial 06 doesn't (fully) take into account browser closing connection #138

Closed Mr-Dispatch closed 2 years ago

Mr-Dispatch commented 2 years ago

I was reading through tut. 06 and it occurred to me: "but after the loop exits because of connection loss, this will surely try to access invalid obj". And sure as hell, when you close the connection while the event handler is still looping, it crashes.

Furthermore, the sleeps give user enough time to close the connection while the thread is asleep and thinks the connection is valid.

EDIT: Now that I looked at it again, probably only the access after the first sleep needs to be guarded.

I'd think about adding a condition for "invalid object access", so handlers could deal with it better (later there could be even macros to make it sweeter).

rabbibotton commented 2 years ago

By design setting properties on objects of a closed connection should not create an error condition. However you did fortunately for us all :) expose that setting a connection data item was creating one. That has been corrected.

Thanks!!!

rabbibotton commented 2 years ago

BTW the reason for this behavior (that it is not an error condition) is that it reduces the need for error condition handling around the UI so the programmer can focus on the program logic, ie the real code. In the case, such is in this tutorial, one needs to know if the UIs state is no longer valid they just check it and react.