FIX: backup switch take effect
Change-Id: Ie9740d7f985ae6adc2778eaac0a80cf7a94c98c4
This commit is contained in:
parent
bda92795bb
commit
9558ed242c
|
@ -286,7 +286,7 @@ void AppConfig::set_defaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get("backup_switch").empty()) {
|
if (get("backup_switch").empty()) {
|
||||||
set_bool("backup_switch", false);
|
set_bool("backup_switch", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get("backup_interval").empty()) {
|
if (get("backup_interval").empty()) {
|
||||||
|
|
|
@ -7397,7 +7397,10 @@ public:
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
while (m_tasks.empty()) {
|
while (m_tasks.empty()) {
|
||||||
|
if (m_interval > 0)
|
||||||
m_cond.timed_wait(lock, m_next_backup);
|
m_cond.timed_wait(lock, m_next_backup);
|
||||||
|
else
|
||||||
|
m_cond.wait(lock);
|
||||||
if (m_interval > 0 && boost::get_system_time() > m_next_backup) {
|
if (m_interval > 0 && boost::get_system_time() > m_next_backup) {
|
||||||
m_tasks.push_back({ Backup, 0, std::string(), nullptr, ++m_task_seq });
|
m_tasks.push_back({ Backup, 0, std::string(), nullptr, ++m_task_seq });
|
||||||
m_next_backup += boost::posix_time::seconds(m_interval);
|
m_next_backup += boost::posix_time::seconds(m_interval);
|
||||||
|
|
|
@ -488,10 +488,14 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
||||||
update_slice_print_status(eEventSliceUpdate, true, true);
|
update_slice_print_status(eEventSliceUpdate, true, true);
|
||||||
|
|
||||||
// BBS: backup project
|
// BBS: backup project
|
||||||
|
if (wxGetApp().app_config->get("backup_switch") == "true") {
|
||||||
std::string backup_interval;
|
std::string backup_interval;
|
||||||
if (!wxGetApp().app_config->get("", "backup_interval", backup_interval))
|
if (!wxGetApp().app_config->get("", "backup_interval", backup_interval))
|
||||||
backup_interval = "10";
|
backup_interval = "10";
|
||||||
Slic3r::set_backup_interval(boost::lexical_cast<long>(backup_interval));
|
Slic3r::set_backup_interval(boost::lexical_cast<long>(backup_interval));
|
||||||
|
} else {
|
||||||
|
Slic3r::set_backup_interval(0);
|
||||||
|
}
|
||||||
Slic3r::set_backup_callback([this](int action) {
|
Slic3r::set_backup_callback([this](int action) {
|
||||||
if (action == 0) {
|
if (action == 0) {
|
||||||
wxPostEvent(this, wxCommandEvent(EVT_BACKUP_POST));
|
wxPostEvent(this, wxCommandEvent(EVT_BACKUP_POST));
|
||||||
|
|
|
@ -415,6 +415,9 @@ wxBoxSizer *PreferencesDialog::create_item_backup_input(wxString title, wxWindow
|
||||||
m_backup_interval_time = input->GetTextCtrl()->GetValue();
|
m_backup_interval_time = input->GetTextCtrl()->GetValue();
|
||||||
app_config->set("backup_interval", std::string(m_backup_interval_time.mb_str()));
|
app_config->set("backup_interval", std::string(m_backup_interval_time.mb_str()));
|
||||||
app_config->save();
|
app_config->save();
|
||||||
|
long backup_interval = 0;
|
||||||
|
m_backup_interval_time.ToLong(&backup_interval);
|
||||||
|
Slic3r::set_backup_interval(backup_interval);
|
||||||
e.Skip();
|
e.Skip();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -422,6 +425,9 @@ wxBoxSizer *PreferencesDialog::create_item_backup_input(wxString title, wxWindow
|
||||||
m_backup_interval_time = input->GetTextCtrl()->GetValue();
|
m_backup_interval_time = input->GetTextCtrl()->GetValue();
|
||||||
app_config->set("backup_interval", std::string(m_backup_interval_time.mb_str()));
|
app_config->set("backup_interval", std::string(m_backup_interval_time.mb_str()));
|
||||||
app_config->save();
|
app_config->save();
|
||||||
|
long backup_interval = 0;
|
||||||
|
m_backup_interval_time.ToLong(&backup_interval);
|
||||||
|
Slic3r::set_backup_interval(backup_interval);
|
||||||
e.Skip();
|
e.Skip();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -553,6 +559,9 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
|
||||||
// backup
|
// backup
|
||||||
if (param == "backup_switch") {
|
if (param == "backup_switch") {
|
||||||
bool pbool = app_config->get("backup_switch") == "true" ? true : false;
|
bool pbool = app_config->get("backup_switch") == "true" ? true : false;
|
||||||
|
std::string backup_interval = "10";
|
||||||
|
app_config->get("backup_interval", backup_interval);
|
||||||
|
Slic3r::set_backup_interval(pbool ? boost::lexical_cast<long>(backup_interval) : 0);
|
||||||
if (m_backup_interval_textinput != nullptr) { m_backup_interval_textinput->Enable(pbool); }
|
if (m_backup_interval_textinput != nullptr) { m_backup_interval_textinput->Enable(pbool); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue