mGUI: Don't attempt to preload files larger than can fit in RAM

This commit is contained in:
Vicki Pfau 2020-11-19 20:12:19 -08:00
parent 2def7289f3
commit 9ae85bdccc
3 changed files with 14 additions and 2 deletions

View File

@ -53,6 +53,7 @@ Other fixes:
- 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

View File

@ -146,7 +146,7 @@ bool mCorePreloadVFCB(struct mCore* core, struct VFile* vf, void (cb)(size_t, si
extern uint32_t* romBuffer;
extern size_t romBufferSize;
if (size > romBufferSize) {
size = romBufferSize;
return false;
}
vfm = VFileFromMemory(romBuffer, size);
#else

View File

@ -387,8 +387,19 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
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);