mupen64plus-core
mupen64plus-core copied to clipboard
M64CORE_STATE_SAVECOMPLETE callback happens too early with M64P_PARALLEL
The problem is that savestates_save_m64p() is further queueing savestates_save_m64p_work(), and yet the callback in savestates_save() happens immediately once savestates_save_m64p() exits, without waiting for the work function to finish.
So if you, say, immediately shut down the core after that callback, it will break.
This only happens with savestates_type_m64p savestates, the pj64 ones are fine, since they aren't async.
And of course since without M64P_PARALLEL there's no work queue and it just calls the function instead, the bug disappears in that case
The simplest solution would be to just do the StateChanged() call in savestates_save_m64p_work(), savestates_save_pj64_zip() or savestates_save_pj64_unc(). (or savestates_save_m64p() too if it exits immediately), instead of savestates_save(). If it's fine, I'll open a PR, not sure if there are implications I'm not aware of.
Ping?
Yes I think your suggestion is the best way to correct this problem; please file a pull request with this change.