From bf06f1e4439ddbe75828a1515aa723bb7c6d978e Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 5 Oct 2016 00:01:11 -0700 Subject: [PATCH] GB: Properly unload save files when unloading a ROM --- CHANGES | 1 + src/gb/gb.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 8a55d4072..2f83f881e 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,7 @@ Bugfixes: - GBA Memory: Fix several unused I/O register read values - Qt: Fix patch loading - Qt: Fix crash when saving an override if a game isn't loaded + - GB: Properly unload save files when unloading a ROM Misc: - All: Only update version info if needed - FFmpeg: Encoding cleanup diff --git a/src/gb/gb.c b/src/gb/gb.c index e6507cf9a..68fc4bcbc 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -253,11 +253,13 @@ void GBUnloadROM(struct GB* gb) { } gb->pristineRom = 0; - struct VFile* vf = gb->sramVf; + GBSavedataUnmask(gb); GBSramDeinit(gb); - if (vf) { - vf->close(vf); + if (gb->sramRealVf) { + gb->sramRealVf->close(gb->sramRealVf); } + gb->sramRealVf = NULL; + gb->sramVf = NULL; } void GBLoadBIOS(struct GB* gb, struct VFile* vf) {