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
dea26b756a
commit
c8d99705b3
1
CHANGES
1
CHANGES
|
@ -15,6 +15,7 @@ Other fixes:
|
||||||
- GBA: Fix maximum tile ID in caching for 256-color modes
|
- GBA: Fix maximum tile ID in caching for 256-color modes
|
||||||
- GBA Video: Fix cache updating with proxy and GL renderers
|
- GBA Video: Fix cache updating with proxy and GL renderers
|
||||||
- Libretro: Fix crash when using Game Boy codes (fixes mgba.io/i/2281)
|
- 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: Remove potentially deadlocking optimization
|
- Qt: Remove potentially deadlocking optimization
|
||||||
- Qt: Fix corrupted savestate and fatal error text
|
- Qt: Fix corrupted savestate and fatal error text
|
||||||
- Qt: Fix sprite compositing when sprite tiles go out of bounds (fixes mgba.io/i/2348)
|
- Qt: Fix sprite compositing when sprite tiles go out of bounds (fixes mgba.io/i/2348)
|
||||||
|
|
|
@ -181,10 +181,10 @@ static void _tryAutosave(struct mGUIRunner* runner) {
|
||||||
#ifdef DISABLE_THREADING
|
#ifdef DISABLE_THREADING
|
||||||
mCoreSaveState(runner->core, 0, SAVESTATE_SAVEDATA | SAVESTATE_RTC | SAVESTATE_METADATA);
|
mCoreSaveState(runner->core, 0, SAVESTATE_SAVEDATA | SAVESTATE_RTC | SAVESTATE_METADATA);
|
||||||
#else
|
#else
|
||||||
|
MutexLock(&runner->autosave.mutex);
|
||||||
if (!runner->autosave.buffer) {
|
if (!runner->autosave.buffer) {
|
||||||
runner->autosave.buffer = VFileMemChunk(NULL, 0);
|
runner->autosave.buffer = VFileMemChunk(NULL, 0);
|
||||||
}
|
}
|
||||||
MutexLock(&runner->autosave.mutex);
|
|
||||||
runner->autosave.core = runner->core;
|
runner->autosave.core = runner->core;
|
||||||
mCoreSaveStateNamed(runner->core, runner->autosave.buffer, SAVESTATE_SAVEDATA | SAVESTATE_RTC | SAVESTATE_METADATA);
|
mCoreSaveStateNamed(runner->core, runner->autosave.buffer, SAVESTATE_SAVEDATA | SAVESTATE_RTC | SAVESTATE_METADATA);
|
||||||
ConditionWake(&runner->autosave.cond);
|
ConditionWake(&runner->autosave.cond);
|
||||||
|
@ -739,7 +739,13 @@ THREAD_ENTRY mGUIAutosaveThread(void* context) {
|
||||||
while (autosave->running) {
|
while (autosave->running) {
|
||||||
ConditionWait(&autosave->cond, &autosave->mutex);
|
ConditionWait(&autosave->cond, &autosave->mutex);
|
||||||
if (autosave->running && autosave->core) {
|
if (autosave->running && autosave->core) {
|
||||||
|
if (!autosave->buffer) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
struct VFile* vf = mCoreGetState(autosave->core, 0, true);
|
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);
|
void* mem = autosave->buffer->map(autosave->buffer, autosave->buffer->size(autosave->buffer), MAP_READ);
|
||||||
vf->write(vf, mem, autosave->buffer->size(autosave->buffer));
|
vf->write(vf, mem, autosave->buffer->size(autosave->buffer));
|
||||||
autosave->buffer->unmap(autosave->buffer, mem, autosave->buffer->size(autosave->buffer));
|
autosave->buffer->unmap(autosave->buffer, mem, autosave->buffer->size(autosave->buffer));
|
||||||
|
|
Loading…
Reference in New Issue