Fix crash with event watchers + handle SDL loop better + shut down more appropriately
This commit is contained in:
@@ -22,14 +22,6 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_sha
|
||||
core->Stop();
|
||||
}
|
||||
});
|
||||
|
||||
emuExitFunc = [&]() {
|
||||
quit = true;
|
||||
if (emuThread.isRunning) {
|
||||
emuThread.requestInterruption();
|
||||
while (emuThread.isRunning) {}
|
||||
}
|
||||
};
|
||||
|
||||
about.setFunc([&]() {
|
||||
ImGui::Text("Kaizen is a Nintendo 64 emulator that strives");
|
||||
@@ -63,7 +55,10 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_sha
|
||||
Util::panic("Error: {}", NFD::GetError());
|
||||
LoadROM(path.get());
|
||||
}},
|
||||
{"Exit", std::move(emuExitFunc)}
|
||||
{"Exit", [&]() {
|
||||
quit = true;
|
||||
emuThread.Stop();
|
||||
}}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -85,6 +80,10 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_sha
|
||||
}});
|
||||
}
|
||||
|
||||
KaizenGui::~KaizenGui() {
|
||||
gui::Cleanup();
|
||||
}
|
||||
|
||||
void KaizenGui::RenderUI() {
|
||||
gui::StartFrame();
|
||||
statusBar.render();
|
||||
@@ -114,17 +113,22 @@ void KaizenGui::LoadROM(const std::string &path) noexcept {
|
||||
Util::RPC::GetInstance().Update(Util::RPC::Playing, gameNameDB);
|
||||
}
|
||||
|
||||
int KaizenGui::run() {
|
||||
void KaizenGui::run() {
|
||||
while(!quit) {
|
||||
if(vulkanWidget.wsiPlatform->quitRequested) {
|
||||
emuExitFunc();
|
||||
emuThread.run();
|
||||
SDL_Event e;
|
||||
while (SDL_PollEvent(&e)) {
|
||||
ImGui_ImplSDL3_ProcessEvent(&e);
|
||||
switch(e.type) {
|
||||
case SDL_EVENT_QUIT:
|
||||
quit = true;
|
||||
emuThread.Stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RenderUI();
|
||||
emuThread.run();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void KaizenGui::LoadTAS(const std::string &path) const noexcept {
|
||||
|
||||
Reference in New Issue
Block a user