Qt: Use safer isLoaded check in GameController

This commit is contained in:
Jeffrey Pfau 2015-10-24 23:45:47 -07:00
parent 2079d47673
commit 6c71d7433b
2 changed files with 11 additions and 10 deletions

View File

@ -5,6 +5,7 @@ Features:
- Booting of multiboot images - Booting of multiboot images
Bugfixes: Bugfixes:
- Util: Fix PowerPC PNG read/write pixel order - Util: Fix PowerPC PNG read/write pixel order
- Qt: Use safer isLoaded check in GameController
Misc: Misc:
- Qt: Window size command line options are now supported - Qt: Window size command line options are now supported
- Qt: Increase usability of key mapper - Qt: Increase usability of key mapper

View File

@ -390,7 +390,7 @@ void GameController::loadPatch(const QString& path) {
} }
void GameController::importSharkport(const QString& path) { void GameController::importSharkport(const QString& path) {
if (!m_gameOpen) { if (!isLoaded()) {
return; return;
} }
VFile* vf = VFileDevice::open(path, O_RDONLY); VFile* vf = VFileDevice::open(path, O_RDONLY);
@ -405,7 +405,7 @@ void GameController::importSharkport(const QString& path) {
} }
void GameController::exportSharkport(const QString& path) { void GameController::exportSharkport(const QString& path) {
if (!m_gameOpen) { if (!isLoaded()) {
return; return;
} }
VFile* vf = VFileDevice::open(path, O_WRONLY | O_CREAT | O_TRUNC); VFile* vf = VFileDevice::open(path, O_WRONLY | O_CREAT | O_TRUNC);
@ -462,7 +462,7 @@ bool GameController::isPaused() {
} }
void GameController::setPaused(bool paused) { void GameController::setPaused(bool paused) {
if (!m_gameOpen || m_rewindTimer.isActive() || paused == GBAThreadIsPaused(&m_threadContext)) { if (!isLoaded() || m_rewindTimer.isActive() || paused == GBAThreadIsPaused(&m_threadContext)) {
return; return;
} }
if (paused) { if (paused) {
@ -614,7 +614,7 @@ void GameController::setAudioChannelEnabled(int channel, bool enable) {
return; return;
} }
m_audioChannels[channel] = enable; m_audioChannels[channel] = enable;
if (m_gameOpen) { if (isLoaded()) {
switch (channel) { switch (channel) {
case 0: case 0:
case 1: case 1:
@ -637,7 +637,7 @@ void GameController::setVideoLayerEnabled(int layer, bool enable) {
return; return;
} }
m_videoLayers[layer] = enable; m_videoLayers[layer] = enable;
if (m_gameOpen) { if (isLoaded()) {
switch (layer) { switch (layer) {
case 0: case 0:
case 1: case 1:
@ -771,7 +771,7 @@ void GameController::setAudioSync(bool set) {
void GameController::setFrameskip(int skip) { void GameController::setFrameskip(int skip) {
threadInterrupt(); threadInterrupt();
m_threadContext.frameskip = skip; m_threadContext.frameskip = skip;
if (m_gameOpen) { if (isLoaded()) {
m_threadContext.gba->video.frameskip = skip; m_threadContext.gba->video.frameskip = skip;
} }
threadContinue(); threadContinue();
@ -780,7 +780,7 @@ void GameController::setFrameskip(int skip) {
void GameController::setVolume(int volume) { void GameController::setVolume(int volume) {
threadInterrupt(); threadInterrupt();
m_threadContext.volume = volume; m_threadContext.volume = volume;
if (m_gameOpen) { if (isLoaded()) {
m_threadContext.gba->audio.masterVolume = volume; m_threadContext.gba->audio.masterVolume = volume;
} }
threadContinue(); threadContinue();
@ -789,7 +789,7 @@ void GameController::setVolume(int volume) {
void GameController::setMute(bool mute) { void GameController::setMute(bool mute) {
threadInterrupt(); threadInterrupt();
m_threadContext.mute = mute; m_threadContext.mute = mute;
if (m_gameOpen) { if (isLoaded()) {
m_threadContext.gba->audio.masterVolume = mute ? 0 : m_threadContext.volume; m_threadContext.gba->audio.masterVolume = mute ? 0 : m_threadContext.volume;
} }
threadContinue(); threadContinue();
@ -837,7 +837,7 @@ void GameController::enableTurbo() {
void GameController::setAVStream(GBAAVStream* stream) { void GameController::setAVStream(GBAAVStream* stream) {
threadInterrupt(); threadInterrupt();
m_threadContext.stream = stream; m_threadContext.stream = stream;
if (m_gameOpen) { if (isLoaded()) {
m_threadContext.gba->stream = stream; m_threadContext.gba->stream = stream;
} }
threadContinue(); threadContinue();
@ -846,7 +846,7 @@ void GameController::setAVStream(GBAAVStream* stream) {
void GameController::clearAVStream() { void GameController::clearAVStream() {
threadInterrupt(); threadInterrupt();
m_threadContext.stream = nullptr; m_threadContext.stream = nullptr;
if (m_gameOpen) { if (isLoaded()) {
m_threadContext.gba->stream = nullptr; m_threadContext.gba->stream = nullptr;
} }
threadContinue(); threadContinue();