mirror of https://github.com/mgba-emu/mgba.git
mGUI: Fix crash if autosave file can't be opened (fixes #2268)
This commit is contained in:
parent
283196ceb3
commit
c9e1b78426
1
CHANGES
1
CHANGES
|
@ -31,6 +31,7 @@ Other fixes:
|
|||
- GBA: Fix maximum tile ID in caching for 256-color modes
|
||||
- GBA Video: Fix cache updating with proxy and GL renderers
|
||||
- Libretro: Fix crash when using Game Boy codes (fixes mgba.io/i/2281)
|
||||
- mGUI: Fix crash if autosave file can't be opened (fixes mgba.io/i/2268)
|
||||
- Qt: Fix corrupted savestate and fatal error text
|
||||
- Qt: Fix sprite compositing when sprite tiles go out of bounds (fixes mgba.io/i/2348)
|
||||
Misc:
|
||||
|
|
|
@ -186,10 +186,10 @@ static void _tryAutosave(struct mGUIRunner* runner) {
|
|||
#ifdef DISABLE_THREADING
|
||||
mCoreSaveState(runner->core, 0, SAVESTATE_SAVEDATA | SAVESTATE_RTC | SAVESTATE_METADATA);
|
||||
#else
|
||||
MutexLock(&runner->autosave.mutex);
|
||||
if (!runner->autosave.buffer) {
|
||||
runner->autosave.buffer = VFileMemChunk(NULL, 0);
|
||||
}
|
||||
MutexLock(&runner->autosave.mutex);
|
||||
runner->autosave.core = runner->core;
|
||||
mCoreSaveStateNamed(runner->core, runner->autosave.buffer, SAVESTATE_SAVEDATA | SAVESTATE_RTC | SAVESTATE_METADATA);
|
||||
ConditionWake(&runner->autosave.cond);
|
||||
|
@ -775,7 +775,13 @@ THREAD_ENTRY mGUIAutosaveThread(void* context) {
|
|||
while (autosave->running) {
|
||||
ConditionWait(&autosave->cond, &autosave->mutex);
|
||||
if (autosave->running && autosave->core) {
|
||||
if (!autosave->buffer) {
|
||||
continue;
|
||||
}
|
||||
struct VFile* vf = mCoreGetState(autosave->core, 0, true);
|
||||
if (!vf) {
|
||||
continue;
|
||||
}
|
||||
void* mem = autosave->buffer->map(autosave->buffer, autosave->buffer->size(autosave->buffer), MAP_READ);
|
||||
vf->write(vf, mem, autosave->buffer->size(autosave->buffer));
|
||||
autosave->buffer->unmap(autosave->buffer, mem, autosave->buffer->size(autosave->buffer));
|
||||
|
|
Loading…
Reference in New Issue