File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ void Engine::frame()
132132
133133 do {
134134 script->run ();
135- if (script->atEnd ()) {
135+ if (script->atEnd () && m_running ) {
136136 for (auto &[key, value] : m_runningBroadcastMap) {
137137 size_t index = 0 ;
138138
@@ -152,6 +152,8 @@ void Engine::frame()
152152 } while (!script->atEnd () && !m_breakFrame);
153153 }
154154
155+ assert (m_running || m_scriptsToRemove.empty ());
156+
155157 for (auto script : m_scriptsToRemove) {
156158 size_t index = -1 ;
157159 for (size_t i = 0 ; i < m_runningScripts.size (); i++) {
@@ -169,6 +171,7 @@ void Engine::frame()
169171void Engine::start ()
170172{
171173 m_timer->reset ();
174+ m_running = true ;
172175
173176 for (auto target : m_targets) {
174177 auto gfBlocks = target->greenFlagBlocks ();
@@ -180,6 +183,8 @@ void Engine::start()
180183void Engine::stop ()
181184{
182185 m_runningScripts.clear ();
186+ m_scriptsToRemove.clear ();
187+ m_running = false ;
183188}
184189
185190void Engine::startScript (std::shared_ptr<Block> topLevelBlock, std::shared_ptr<Target> target)
@@ -344,6 +349,8 @@ void Engine::run()
344349
345350 lastFrameTime = currentTime;
346351 }
352+
353+ stop ();
347354}
348355
349356bool Engine::broadcastRunning (unsigned int index, VirtualMachine *sourceScript)
Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ class Engine : public IEngine
108108 std::unique_ptr<ITimer> m_defaultTimer;
109109 ITimer *m_timer = nullptr ;
110110
111+ bool m_running = false ;
111112 bool m_breakFrame = false ;
112113 bool m_skipFrame = false ;
113114 bool m_lockFrame = false ;
You can’t perform that action at this time.
0 commit comments