diff --git a/CHANGES b/CHANGES index 31c148651..d66552044 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,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 d467b6da2..f8b69c460 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) {