Fix: Defer EmuThread start to fix shortcut launch hang

a race condition where the BootGame() function was called directly from the GMainWindow constructor. This would create and start the EmuThread before the main Qt application event loop (app.exec()) had begun. As a result, the LoadingScreen UI was not fully initialized and could not properly process the progress signals from the background emulation thread, causing the hang.

The fix defers the call to emu_thread->start() by wrapping it in a QTimer::singleShot(0, ...) with a lambda function. This places the start command on the Qt event queue, ensuring it only executes after the GMainWindow has been fully constructed and the event loop is active. This guarantees the UI is ready to receive signals, resolving the race condition.

Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
Collecting
2026-01-31 22:39:59 +01:00
parent 22a458a53c
commit ef22699020

View File

@@ -2183,8 +2183,8 @@ void GMainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletP
connect(emu_thread.get(), &EmuThread::LoadProgress, loading_screen,
&LoadingScreen::OnLoadProgress, Qt::QueuedConnection);
// Start the thread AFTER all connections are set up
emu_thread->start();
// Start the thread AFTER all connections are set up and the event loop has started
QTimer::singleShot(0, this, [this] { emu_thread->start(); });
// Update the GUI
UpdateStatusButtons();