mGUI: Don't attempt to preload files larger than can fit in RAM
Vicki Pfau vi@endrift.com
Thu, 19 Nov 2020 20:12:19 -0800
3 files changed,
14 insertions(+),
2 deletions(-)
M
CHANGES
→
CHANGES
@@ -53,6 +53,7 @@ - Debugger: Don't skip undefined instructions when debugger attached
- Debugger: Close trace log when done tracing - FFmpeg: Fix some small memory leaks - FFmpeg: Fix encoding of time base + - mGUI: Don't attempt to preload files larger than can fit in RAM - Qt: Force OpenGL paint engine creation thread (fixes mgba.io/i/1642) - Qt: Fix static compilation in MinGW (fixes mgba.io/i/1769) - Qt: Fix a race condition in the frame inspector
M
src/core/core.c
→
src/core/core.c
@@ -146,7 +146,7 @@ #ifdef FIXED_ROM_BUFFER
extern uint32_t* romBuffer; extern size_t romBufferSize; if (size > romBufferSize) { - size = romBufferSize; + return false; } vfm = VFileFromMemory(romBuffer, size); #else
M
src/feature/gui/gui-runner.c
→
src/feature/gui/gui-runner.c
@@ -387,8 +387,19 @@ runner->core->init(runner->core);
mCoreInitConfig(runner->core, runner->port); mInputMapInit(&runner->core->inputMap, &GBAInputInfo); - found = mCorePreloadFileCB(runner->core, path, _updateLoading, runner); + struct VFile* rom = mDirectorySetOpenPath(&runner->core->dirs, path, runner->core->isROM); + found = mCorePreloadVFCB(runner->core, rom, _updateLoading, runner); + +#ifdef FIXED_ROM_BUFFER + extern size_t romBufferSize; + if (!found && rom && (size_t) rom->size(rom) > romBufferSize) { + found = runner->core->loadROM(runner->core, rom); + } +#endif if (!found) { + if (rom) { + rom->close(rom); + } mLOG(GUI_RUNNER, WARN, "Failed to load %s!", path); mCoreConfigDeinit(&runner->core->config); runner->core->deinit(runner->core);