diff --git a/src/gb/core.c b/src/gb/core.c index 95bf8b2f5..aacadde1d 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -74,6 +74,7 @@ static void _GBCoreDeinit(struct mCore* core) { mCheatDeviceDestroy(gbcore->cheatDevice); } free(gbcore->cheatDevice); + mCoreConfigFreeOpts(&core->opts); free(core); } diff --git a/src/gb/gb.c b/src/gb/gb.c index b3c874747..96fef6762 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -221,6 +221,11 @@ void GBApplyPatch(struct GB* gb, struct Patch* patch) { void GBDestroy(struct GB* gb) { GBUnloadROM(gb); + if (gb->biosVf) { + gb->biosVf->close(gb->biosVf); + gb->biosVf = 0; + } + GBMemoryDeinit(gb); GBVideoDeinit(&gb->video); GBSIODeinit(&gb->sio); diff --git a/src/gba/core.c b/src/gba/core.c index cd2b2cda3..24f984cdb 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -92,6 +92,7 @@ static void _GBACoreDeinit(struct mCore* core) { mCheatDeviceDestroy(gbacore->cheatDevice); } free(gbacore->cheatDevice); + mCoreConfigFreeOpts(&core->opts); free(core); } diff --git a/src/gba/gba.c b/src/gba/gba.c index 674da776f..bb5f578d1 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -140,6 +140,8 @@ void GBADestroy(struct GBA* gba) { if (gba->biosVf) { gba->biosVf->unmap(gba->biosVf, gba->memory.bios, SIZE_BIOS); + gba->biosVf->close(gba->biosVf); + gba->biosVf = 0; } GBAMemoryDeinit(gba); diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 08b461b2e..215cfb248 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -406,9 +406,8 @@ void GameController::openGame(bool biosOnly) { if (!m_bios.isNull() && m_useBios) { VFile* bios = VFileDevice::open(m_bios, O_RDONLY); - if (bios) { - // TODO: Lifetime issues? - m_threadContext.core->loadBIOS(m_threadContext.core, bios, 0); + if (bios && !m_threadContext.core->loadBIOS(m_threadContext.core, bios, 0)) { + bios->close(bios); } }