mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Fix occasional crash
This commit is contained in:
parent
458aeae4c8
commit
a222f59c15
@ -256,11 +256,15 @@ export class Application {
|
|||||||
onAppRenderableStateChanged(renderable) {
|
onAppRenderableStateChanged(renderable) {
|
||||||
logger.log("Application renderable:", renderable);
|
logger.log("Application renderable:", renderable);
|
||||||
window.focus();
|
window.focus();
|
||||||
|
const currentState = this.stateMgr.getCurrentState();
|
||||||
if (!renderable) {
|
if (!renderable) {
|
||||||
this.stateMgr.getCurrentState().onAppPause();
|
if (currentState) {
|
||||||
|
currentState.onAppPause();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Got resume
|
if (currentState) {
|
||||||
this.stateMgr.getCurrentState().onAppResume();
|
currentState.onAppResume();
|
||||||
|
}
|
||||||
this.checkResize();
|
this.checkResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +278,10 @@ export class Application {
|
|||||||
if (!this.unloaded) {
|
if (!this.unloaded) {
|
||||||
logSection("UNLOAD HANDLER", "#f77");
|
logSection("UNLOAD HANDLER", "#f77");
|
||||||
this.unloaded = true;
|
this.unloaded = true;
|
||||||
this.stateMgr.getCurrentState().onBeforeExit();
|
const currentState = this.stateMgr.getCurrentState();
|
||||||
|
if (currentState) {
|
||||||
|
currentState.onBeforeExit();
|
||||||
|
}
|
||||||
this.deinitialize();
|
this.deinitialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,8 +291,9 @@ export class Application {
|
|||||||
*/
|
*/
|
||||||
onBeforeUnload(event) {
|
onBeforeUnload(event) {
|
||||||
logSection("BEFORE UNLOAD HANDLER", "#f77");
|
logSection("BEFORE UNLOAD HANDLER", "#f77");
|
||||||
|
const currentState = this.stateMgr.getCurrentState();
|
||||||
|
|
||||||
if (!G_IS_DEV && this.stateMgr.getCurrentState().getHasUnloadConfirmation()) {
|
if (!G_IS_DEV && currentState && currentState.getHasUnloadConfirmation()) {
|
||||||
if (!G_IS_STANDALONE) {
|
if (!G_IS_STANDALONE) {
|
||||||
// Need to show a "Are you sure you want to exit"
|
// Need to show a "Are you sure you want to exit"
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -335,7 +343,10 @@ export class Application {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.stateMgr.getCurrentState().onBackgroundTick(dt);
|
const currentState = this.stateMgr.getCurrentState();
|
||||||
|
if (currentState) {
|
||||||
|
currentState.onBackgroundTick(dt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -355,7 +366,10 @@ export class Application {
|
|||||||
this.lastResizeCheck = time;
|
this.lastResizeCheck = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.stateMgr.getCurrentState().onRender(dt);
|
const currentState = this.stateMgr.getCurrentState();
|
||||||
|
if (currentState) {
|
||||||
|
currentState.onRender(dt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user