mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
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.
This commit is contained in:
@ -118,8 +118,7 @@ void Host_Message(HostMessageID id)
|
||||
}
|
||||
else if (id == HostMessageID::WMUserStop)
|
||||
{
|
||||
if (Core::IsRunning(Core::System::GetInstance()))
|
||||
Core::QueueHostJob(&Core::Stop);
|
||||
Core::QueueHostJob(&Core::Stop);
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,13 +270,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetIsBooting
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunning(JNIEnv*, jclass)
|
||||
{
|
||||
return s_is_booting.IsSet() ||
|
||||
static_cast<jboolean>(Core::IsRunning(Core::System::GetInstance()));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunningAndStarted(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
return static_cast<jboolean>(Core::IsRunning(Core::System::GetInstance()));
|
||||
}
|
||||
@ -288,6 +280,13 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunningAndUnpaused(JNIEnv*, jclas
|
||||
return static_cast<jboolean>(Core::GetState(Core::System::GetInstance()) == Core::State::Running);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsUninitialized(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
return static_cast<jboolean>(Core::IsUninitialized(Core::System::GetInstance()) &&
|
||||
!s_is_booting.IsSet());
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env,
|
||||
jclass)
|
||||
{
|
||||
|
Reference in New Issue
Block a user