fix datasaved being called too late

This commit is contained in:
dankmeme01 2024-09-13 18:57:51 +02:00
parent 4ad9c848c0
commit 8615bbd52f

View file

@ -225,6 +225,9 @@ Result<> Mod::Impl::saveData() {
matjson::Value json = m_savedSettingsData;
m_settings->save(json);
// saveData is expected to be synchronous, and always called from GD thread
ModStateEvent(m_self, ModEventType::DataSaved).post();
auto res = utils::file::writeString(m_saveDirPath / "settings.json", json.dump());
if (!res) {
log::error("Unable to save settings: {}", res.unwrapErr());
@ -234,9 +237,6 @@ Result<> Mod::Impl::saveData() {
log::error("Unable to save values: {}", res2.unwrapErr());
}
// saveData is expected to be synchronous, and always called from GD thread
ModStateEvent(m_self, ModEventType::DataSaved).post();
return Ok();
}