[ion/simulator] Add Termination event when headless

This commit is contained in:
Romain Goyet
2020-09-16 12:04:31 -04:00
committed by Léa Saviot
parent e8f1ea6aa5
commit c3c7651ca8

View File

@@ -1,5 +1,6 @@
#include "actions.h"
#include "events.h"
#include "journal.h"
#include "keyboard.h"
#include "layout.h"
#include "state_file.h"
@@ -182,6 +183,13 @@ Event getPlatformEvent() {
* the subsequent ones. */
SDL_FlushEvents(0, UINT32_MAX);
}
if (Simulator::Window::isHeadless()) {
if (Simulator::Journal::replayJournal() == nullptr || Simulator::Journal::replayJournal()->isEmpty()) {
/* We don't want to keep the simulator process alive if there's no chance
* we're ever going to provide it with new events to process. */
return Termination;
}
}
return result;
}