History

Fix entity script event crash, script restart and shutdown crashes

ksuprynowicz committed 5 months ago

Commit 780d8721 parent 3198fca2 files · +99 −25Browse files

Showing the changes to libraries/script-engine/src/ScriptManager.cpp (1 of 2 files). Show all

Unified · Split

libraries/script-engine/src/ScriptManager.cpp+7−0
@@ -550,6 +550,8 @@ void ScriptManager::waitTillDoneRunning(bool shutdown) { · 549 unmodified lines
550550 // if they access Settings or Menu in any of their shutdown code. So:
551551 // Process events for this thread, allowing invokeMethod calls to pass between threads.
552552 QCoreApplication::processEvents();
553+ // Events may use script engine so guard is necessary.
554+ auto scopeGuard = _engine->getScopeGuard();
553555 _engine->processEvents();
554556 }
555557
@@ -1224,6 +1226,11 @@ void ScriptManager::timerFired() { · 668 unmodified lines
12241226 return; // bail early
12251227 }
12261228
1229+ // Timer events shouldn't be processed after the script engine has shut down.
1230+ if (_isDoneRunning) {
1231+ return;
1232+ }
1233+
12271234 //#define SCRIPT_TIMER_PERFORMANCE_STATISTICS
12281235 #ifdef SCRIPT_TIMER_PERFORMANCE_STATISTICS
12291236 _timerCallCounter++;