FIX: 3733 backup time not effective

Jira: 3733

Change-Id: I50c2ce156fcbd0a17aa8a6777bce04aa6093c830
Signed-off-by: maosheng.wei <maosheng.wei@bambulab.com>
This commit is contained in:
maosheng.wei 2023-11-15 13:11:25 +08:00 committed by Lane.Wei
parent a888747755
commit 417d2eeb90
3 changed files with 15 additions and 11 deletions

View File

@ -7715,10 +7715,12 @@ public:
void set_interval(long n) {
boost::lock_guard lock(m_mutex);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " entry, and last interval is: " << m_interval;
m_next_backup -= boost::posix_time::seconds(m_interval);
m_interval = n;
m_next_backup += boost::posix_time::seconds(m_interval);
m_cond.notify_all();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " exit, and new interval is: " << m_interval;
}
void put_other_changes()
@ -7796,6 +7798,7 @@ private:
};
private:
_BBS_Backup_Manager() {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " inital and interval = " << m_interval;
m_next_backup = boost::get_system_time() + boost::posix_time::seconds(m_interval);
boost::unique_lock lock(m_mutex);
m_thread = std::move(boost::thread(boost::ref(*this)));
@ -7824,7 +7827,7 @@ private:
}
void process_ui_task(Task& t, bool canceled = false) {
BOOST_LOG_TRIVIAL(info) << "process_ui_task" << t.to_string();
BOOST_LOG_TRIVIAL(info) << "process_ui_task" << t.to_string() << " and interval = " << m_interval;
switch (t.type) {
case Backup: {
if (canceled)
@ -7868,7 +7871,7 @@ private:
}
void process_task(Task& t) {
BOOST_LOG_TRIVIAL(info) << "process_task" << t.to_string();
BOOST_LOG_TRIVIAL(info) << "process_task" << t.to_string() << " and interval = " << m_interval;
switch (t.type) {
case Backup:
// do it in response

View File

@ -573,7 +573,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
// BBS: backup project
if (wxGetApp().app_config->get("backup_switch") == "true") {
std::string backup_interval;
if (!wxGetApp().app_config->get("", "backup_interval", backup_interval))
if (!wxGetApp().app_config->get("app", "backup_interval", backup_interval))
backup_interval = "10";
Slic3r::set_backup_interval(boost::lexical_cast<long>(backup_interval));
} else {

View File

@ -476,6 +476,8 @@ wxBoxSizer *PreferencesDialog::create_item_backup_input(wxString title, wxWindow
StateColor input_bg(std::pair<wxColour, int>(wxColour("#F0F0F1"), StateColor::Disabled), std::pair<wxColour, int>(*wxWHITE, StateColor::Enabled));
input->SetBackgroundColor(input_bg);
input->GetTextCtrl()->SetValue(app_config->get(param));
wxTextValidator validator(wxFILTER_DIGITS);
input->GetTextCtrl()->SetValidator(validator);
auto second_title = new wxStaticText(parent, wxID_ANY, _L("Second"), wxDefaultPosition, DESIGN_TITLE_SIZE, 0);
@ -496,23 +498,22 @@ wxBoxSizer *PreferencesDialog::create_item_backup_input(wxString title, wxWindow
e.Skip();
});
input->GetTextCtrl()->Bind(wxEVT_TEXT_ENTER, [this, param, input](wxCommandEvent &e) {
std::function<void()> backup_interval = [this, param, input]() {
m_backup_interval_time = input->GetTextCtrl()->GetValue();
app_config->set("backup_interval", std::string(m_backup_interval_time.mb_str()));
app_config->save();
long backup_interval = 0;
m_backup_interval_time.ToLong(&backup_interval);
Slic3r::set_backup_interval(backup_interval);
};
input->GetTextCtrl()->Bind(wxEVT_TEXT_ENTER, [backup_interval](wxCommandEvent &e) {
backup_interval();
e.Skip();
});
input->GetTextCtrl()->Bind(wxEVT_KILL_FOCUS, [this, param, input](wxFocusEvent &e) {
m_backup_interval_time = input->GetTextCtrl()->GetValue();
app_config->set("backup_interval", std::string(m_backup_interval_time.mb_str()));
app_config->save();
long backup_interval = 0;
m_backup_interval_time.ToLong(&backup_interval);
Slic3r::set_backup_interval(backup_interval);
input->GetTextCtrl()->Bind(wxEVT_KILL_FOCUS, [backup_interval](wxFocusEvent &e) {
backup_interval();
e.Skip();
});