PresetUpdater: Fix a race condition

This commit is contained in:
Vojtech Kral 2019-02-14 16:51:41 +01:00
parent d8c7966bec
commit e6f7af64a7
3 changed files with 11 additions and 7 deletions

View file

@ -127,6 +127,10 @@ bool GUI_App::OnInit()
app_config->save(); app_config->save();
preset_updater = new PresetUpdater(); preset_updater = new PresetUpdater();
Bind(EVT_SLIC3R_VERSION_ONLINE, [this](const wxCommandEvent &evt) {
app_config->set("version_online", into_u8(evt.GetString()));
app_config->save();
});
load_language(); load_language();

View file

@ -103,6 +103,8 @@ static Semver get_slic3r_version()
return *res; return *res;
} }
wxDEFINE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);
struct PresetUpdater::priv struct PresetUpdater::priv
{ {
@ -225,13 +227,9 @@ void PresetUpdater::priv::sync_version() const
boost::trim(body); boost::trim(body);
BOOST_LOG_TRIVIAL(info) << boost::format("Got Slic3rPE online version: `%1%`. Sending to GUI thread...") % body; BOOST_LOG_TRIVIAL(info) << boost::format("Got Slic3rPE online version: `%1%`. Sending to GUI thread...") % body;
// FIXME: race condition wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
evt->SetString(GUI::from_u8(body));
// wxCommandEvent* evt = new wxCommandEvent(version_online_event); GUI::wxGetApp().QueueEvent(evt);
// evt->SetString(body);
// GUI::get_app()->QueueEvent(evt);
GUI::wxGetApp().app_config->set("version_online", body);
GUI::wxGetApp().app_config->save();
}) })
.perform_sync(); .perform_sync();
} }

View file

@ -37,6 +37,8 @@ private:
std::unique_ptr<priv> p; std::unique_ptr<priv> p;
}; };
wxDECLARE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);
} }
#endif #endif