From e0c575042e80c082c8af4d67e15f409f80dce550 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 13 Apr 2024 14:09:36 -0500 Subject: [PATCH] GUI: fix crash when using MinMod in init pres conf --- src/gui/sysConf.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index 324ca722e..653a7b299 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -453,13 +453,17 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl if (sampRate>65536) sampRate=65536; altered=true; } rightClickable - DivPlatformGBAMinMod* dispatch=(DivPlatformGBAMinMod*)e->getDispatch(chan); - float maxCPU=dispatch->maxCPU*100; - ImGui::Text("Actual sample rate: %d Hz", dispatch->chipClock); - if (maxCPU>90) ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_WARNING]); - ImGui::Text("Max mixer CPU usage: %.0f%%", maxCPU); - if (maxCPU>90) ImGui::PopStyleColor(); - FurnaceGUI::popWarningColor(); + if (chan>=0) { + DivPlatformGBAMinMod* dispatch=(DivPlatformGBAMinMod*)e->getDispatch(chan); + if (dispatch!=NULL) { + float maxCPU=dispatch->maxCPU*100; + ImGui::Text("Actual sample rate: %d Hz", dispatch->chipClock); + if (maxCPU>90) ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_WARNING]); + ImGui::Text("Max mixer CPU usage: %.0f%%",maxCPU); + if (maxCPU>90) ImGui::PopStyleColor(); + FurnaceGUI::popWarningColor(); + } + } if (altered) { e->lockSave([&]() { flags.set("volScale",volScale);