Merge pull request #13077 from Dentomologist/graphicswindow_fix_first_opening_during_emulation_startup_crash

GraphicsWindow: Fix crash when opening for the first time during emulation startup
This commit is contained in:
Tilka 2024-09-27 05:38:37 +01:00 committed by GitHub
commit 61836e5d8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 13 deletions

View File

@ -573,8 +573,6 @@ static void EmuThread(Core::System& system, std::unique_ptr<BootParameters> boot
system.GetPowerPC().GetDebugInterface().Clear(guard); system.GetPowerPC().GetDebugInterface().Clear(guard);
}}; }};
VideoBackendBase::PopulateBackendInfo(wsi);
if (!g_video_backend->Initialize(wsi)) if (!g_video_backend->Initialize(wsi))
{ {
PanicAlertFmt("Failed to initialize video backend!"); PanicAlertFmt("Failed to initialize video backend!");

View File

@ -67,7 +67,7 @@ void GraphicsWindow::CreateMainLayout()
void GraphicsWindow::OnBackendChanged(const QString& backend_name) void GraphicsWindow::OnBackendChanged(const QString& backend_name)
{ {
VideoBackendBase::PopulateBackendInfoFromUI(m_main_window->GetWindowSystemInfo()); VideoBackendBase::PopulateBackendInfo(m_main_window->GetWindowSystemInfo());
setWindowTitle( setWindowTitle(
tr("%1 Graphics Configuration").arg(tr(g_video_backend->GetDisplayName().c_str()))); tr("%1 Graphics Configuration").arg(tr(g_video_backend->GetDisplayName().c_str())));

View File

@ -284,6 +284,11 @@ void VideoBackendBase::ActivateBackend(const std::string& name)
void VideoBackendBase::PopulateBackendInfo(const WindowSystemInfo& wsi) void VideoBackendBase::PopulateBackendInfo(const WindowSystemInfo& wsi)
{ {
// If the core is running, the backend info will have been populated already. If we did it here,
// the UI thread could race with the GPU thread.
if (Core::IsRunningOrStarting(Core::System::GetInstance()))
return;
g_Config.Refresh(); g_Config.Refresh();
// Reset backend_info so if the backend forgets to initialize something it doesn't end up using // Reset backend_info so if the backend forgets to initialize something it doesn't end up using
// a value from the previously used renderer // a value from the previously used renderer
@ -296,14 +301,6 @@ void VideoBackendBase::PopulateBackendInfo(const WindowSystemInfo& wsi)
g_Config.VerifyValidity(); g_Config.VerifyValidity();
} }
void VideoBackendBase::PopulateBackendInfoFromUI(const WindowSystemInfo& wsi)
{
// If the core is running, the backend info will have been populated already.
// If we did it here, the UI thread can race with the with the GPU thread.
if (!Core::IsRunning(Core::System::GetInstance()))
PopulateBackendInfo(wsi);
}
void VideoBackendBase::DoState(PointerWrap& p) void VideoBackendBase::DoState(PointerWrap& p)
{ {
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();

View File

@ -70,8 +70,6 @@ public:
// Fills the backend_info fields with the capabilities of the selected backend/device. // Fills the backend_info fields with the capabilities of the selected backend/device.
static void PopulateBackendInfo(const WindowSystemInfo& wsi); static void PopulateBackendInfo(const WindowSystemInfo& wsi);
// Called by the UI thread when the graphics config is opened.
static void PopulateBackendInfoFromUI(const WindowSystemInfo& wsi);
// Wrapper function which pushes the event to the GPU thread. // Wrapper function which pushes the event to the GPU thread.
void DoState(PointerWrap& p); void DoState(PointerWrap& p);