From 72cf2bdb87f09deff22e1085de3290126aa4ad05 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 2 Jun 2024 16:45:30 +0200 Subject: Audit uses of IsRunning and GetState Some pieces of code are calling IsRunning because there's some particular action that only makes sense when emulation is running, for instance showing the state of the emulated CPU. IsRunning is appropriate to use for this. Then there are pieces of code that are calling IsRunning because there's some particular thing they must avoid doing e.g. when the CPU thread is running or IOS is running. IsRunning isn't quite appropriate for this. Such code should also be checking for the states Starting and Stopping. Keep in mind that: * When the state is Starting, the state can asynchronously change to Running at any time. * When we try to stop the core, the state gets set to Stopping before we take any action to actually stop things. This commit adds a new method Core::IsUninitialized, and changes all callers of IsRunning and GetState that look to me like they should be changed. --- Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp') diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp index 0d93614021..ccc63fe326 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp @@ -43,8 +43,7 @@ AdvancedWidget::AdvancedWidget(GraphicsWindow* parent) }); OnBackendChanged(); - OnEmulationStateChanged(Core::GetState(Core::System::GetInstance()) != - Core::State::Uninitialized); + OnEmulationStateChanged(!Core::IsUninitialized(Core::System::GetInstance())); } void AdvancedWidget::CreateWidgets() -- cgit v1.2.3