Make stopping emulation not pause or crash UI

* Make the UI and main thread available when stopping emulation.
* Make BlockingCallFromMainThread always execute, preventing bugs when it unexpectedly did not.
* Add error code for when starting emulation when Emu.Kill() is in progress.
This commit is contained in:
Eladash 2023-06-16 21:05:35 +03:00 committed by Megamouse
parent 4f5348c7d4
commit d34b3190f7
8 changed files with 445 additions and 291 deletions

View file

@ -10,6 +10,8 @@
#include <clocale>
[[noreturn]] void report_fatal_error(std::string_view text, bool is_html = false, bool include_help_text = true);
// For now, a trivial constructor/destructor. May add command line usage later.
headless_application::headless_application(int& argc, char** argv) : QCoreApplication(argc, argv)
{
@ -137,6 +139,14 @@ void headless_application::InitializeCallbacks()
callbacks.on_resume = []() {};
callbacks.on_stop = []() {};
callbacks.on_ready = []() {};
callbacks.on_emulation_stop_no_response = [](std::shared_ptr<atomic_t<bool>> closed_successfully, int /*seconds_waiting_already*/)
{
if (!closed_successfully || !*closed_successfully)
{
report_fatal_error(tr("Stopping emulator took too long."
"\nSome thread has probably deadlocked. Aborting.").toStdString());
}
};
callbacks.enable_disc_eject = [](bool) {};
callbacks.enable_disc_insert = [](bool) {};