Web: Fix canvas not auto clearing when client is exited with an error (e.g. invalid port)

This commit is contained in:
UnknownShadow200 2021-10-07 20:32:26 +11:00
parent d3a9477470
commit 1c786570e4
2 changed files with 10 additions and 2 deletions

View File

@ -358,7 +358,12 @@ cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) {
*-----------------------------------------------------Process/Module------------------------------------------------------* *-----------------------------------------------------Process/Module------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
cc_result Process_StartGame(const cc_string* args) { return ERR_NOT_SUPPORTED; } cc_result Process_StartGame(const cc_string* args) { return ERR_NOT_SUPPORTED; }
void Process_Exit(cc_result code) { exit(code); } void Process_Exit(cc_result code) {
/* Window isn't implicitly closed when process is exited */
if (code) Window_Close();
exit(code);
}
extern int interop_OpenTab(const char* url); extern int interop_OpenTab(const char* url);
cc_result Process_StartOpen(const cc_string* args) { cc_result Process_StartOpen(const cc_string* args) {

View File

@ -488,6 +488,9 @@ void Window_Close(void) {
Window_DisableRawMouse(); Window_DisableRawMouse();
Window_SetSize(0, 0); Window_SetSize(0, 0);
UnhookEvents(); UnhookEvents();
/* Game_DoFrame doesn't do anything when WindowExists.False is false, */
/* but it's still better to cancel main loop to minimise resource usage */
emscripten_cancel_main_loop();
} }
extern void interop_RequestCanvasResize(void); extern void interop_RequestCanvasResize(void);