mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 11:23:42 +00:00
FIX: Background process stuck after closing client
Jira: STUDIO-11596 Change-Id: I32fd92c504c16e04d5361d428d4cf5da2960548c (cherry picked from commit fa435310a1082660dd1c9f7fbf815a396eca79a0)
This commit is contained in:
@@ -1009,7 +1009,7 @@ void GUI_App::post_init()
|
|||||||
if(!m_networking_need_update && m_agent) {
|
if(!m_networking_need_update && m_agent) {
|
||||||
m_agent->set_on_ssdp_msg_fn(
|
m_agent->set_on_ssdp_msg_fn(
|
||||||
[this](std::string json_str) {
|
[this](std::string json_str) {
|
||||||
if (m_is_closing) {
|
if (is_closing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GUI::wxGetApp().CallAfter([this, json_str] {
|
GUI::wxGetApp().CallAfter([this, json_str] {
|
||||||
@@ -1118,7 +1118,7 @@ void GUI_App::shutdown()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_is_recreating_gui) return;
|
if (m_is_recreating_gui) return;
|
||||||
m_is_closing = true;
|
set_closing(true);
|
||||||
BOOST_LOG_TRIVIAL(info) << "GUI_App::shutdown exit";
|
BOOST_LOG_TRIVIAL(info) << "GUI_App::shutdown exit";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1538,7 +1538,7 @@ void GUI_App::restart_networking()
|
|||||||
init_networking_callbacks();
|
init_networking_callbacks();
|
||||||
m_agent->set_on_ssdp_msg_fn(
|
m_agent->set_on_ssdp_msg_fn(
|
||||||
[this](std::string json_str) {
|
[this](std::string json_str) {
|
||||||
if (m_is_closing) {
|
if (is_closing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GUI::wxGetApp().CallAfter([this, json_str] {
|
GUI::wxGetApp().CallAfter([this, json_str] {
|
||||||
@@ -1664,7 +1664,7 @@ void GUI_App::init_networking_callbacks()
|
|||||||
|
|
||||||
|
|
||||||
m_agent->set_on_server_connected_fn([this](int return_code, int reason_code) {
|
m_agent->set_on_server_connected_fn([this](int return_code, int reason_code) {
|
||||||
if (m_is_closing) {
|
if (is_closing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (return_code == 5) {
|
if (return_code == 5) {
|
||||||
@@ -1678,7 +1678,7 @@ void GUI_App::init_networking_callbacks()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GUI::wxGetApp().CallAfter([this] {
|
GUI::wxGetApp().CallAfter([this] {
|
||||||
if (m_is_closing)
|
if (is_closing())
|
||||||
return;
|
return;
|
||||||
BOOST_LOG_TRIVIAL(trace) << "static: server connected";
|
BOOST_LOG_TRIVIAL(trace) << "static: server connected";
|
||||||
m_agent->set_user_selected_machine(m_agent->get_user_selected_machine());
|
m_agent->set_user_selected_machine(m_agent->get_user_selected_machine());
|
||||||
@@ -1716,11 +1716,11 @@ void GUI_App::init_networking_callbacks()
|
|||||||
});
|
});
|
||||||
|
|
||||||
m_agent->set_on_printer_connected_fn([this](std::string dev_id) {
|
m_agent->set_on_printer_connected_fn([this](std::string dev_id) {
|
||||||
if (m_is_closing) {
|
if (is_closing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GUI::wxGetApp().CallAfter([this, dev_id] {
|
GUI::wxGetApp().CallAfter([this, dev_id] {
|
||||||
if (m_is_closing)
|
if (is_closing())
|
||||||
return;
|
return;
|
||||||
bool tunnel = boost::algorithm::starts_with(dev_id, "tunnel/");
|
bool tunnel = boost::algorithm::starts_with(dev_id, "tunnel/");
|
||||||
/* request_pushing */
|
/* request_pushing */
|
||||||
@@ -1753,11 +1753,11 @@ void GUI_App::init_networking_callbacks()
|
|||||||
|
|
||||||
m_agent->set_on_local_connect_fn(
|
m_agent->set_on_local_connect_fn(
|
||||||
[this](int state, std::string dev_id, std::string msg) {
|
[this](int state, std::string dev_id, std::string msg) {
|
||||||
if (m_is_closing) {
|
if (is_closing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CallAfter([this, state, dev_id, msg] {
|
CallAfter([this, state, dev_id, msg] {
|
||||||
if (m_is_closing) {
|
if (is_closing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* request_pushing */
|
/* request_pushing */
|
||||||
@@ -1824,11 +1824,11 @@ void GUI_App::init_networking_callbacks()
|
|||||||
);
|
);
|
||||||
|
|
||||||
auto message_arrive_fn = [this](std::string dev_id, std::string msg) {
|
auto message_arrive_fn = [this](std::string dev_id, std::string msg) {
|
||||||
if (m_is_closing) {
|
if (is_closing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CallAfter([this, dev_id, msg] {
|
CallAfter([this, dev_id, msg] {
|
||||||
if (m_is_closing)
|
if (is_closing())
|
||||||
return;
|
return;
|
||||||
this->process_network_msg(dev_id, msg);
|
this->process_network_msg(dev_id, msg);
|
||||||
|
|
||||||
@@ -1858,11 +1858,11 @@ void GUI_App::init_networking_callbacks()
|
|||||||
m_agent->set_on_message_fn(message_arrive_fn);
|
m_agent->set_on_message_fn(message_arrive_fn);
|
||||||
|
|
||||||
auto user_message_arrive_fn = [this](std::string user_id, std::string msg) {
|
auto user_message_arrive_fn = [this](std::string user_id, std::string msg) {
|
||||||
if (m_is_closing) {
|
if (is_closing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CallAfter([this, user_id, msg] {
|
CallAfter([this, user_id, msg] {
|
||||||
if (m_is_closing)
|
if (is_closing())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//check user
|
//check user
|
||||||
@@ -1877,11 +1877,11 @@ void GUI_App::init_networking_callbacks()
|
|||||||
|
|
||||||
|
|
||||||
auto lan_message_arrive_fn = [this](std::string dev_id, std::string msg) {
|
auto lan_message_arrive_fn = [this](std::string dev_id, std::string msg) {
|
||||||
if (m_is_closing) {
|
if (is_closing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CallAfter([this, dev_id, msg] {
|
CallAfter([this, dev_id, msg] {
|
||||||
if (m_is_closing)
|
if (is_closing())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this->process_network_msg(dev_id, msg);
|
this->process_network_msg(dev_id, msg);
|
||||||
@@ -5302,7 +5302,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
cancelFn = [this, dlg]() {
|
cancelFn = [this, dlg]() {
|
||||||
return m_is_closing || dlg->WasCanceled();
|
return is_closing() || dlg->WasCanceled();
|
||||||
};
|
};
|
||||||
finishFn = [this, userid = m_agent->get_user_id(), dlg, t = std::weak_ptr<int>(m_user_sync_token)](bool ok) {
|
finishFn = [this, userid = m_agent->get_user_id(), dlg, t = std::weak_ptr<int>(m_user_sync_token)](bool ok) {
|
||||||
CallAfter([=]{
|
CallAfter([=]{
|
||||||
@@ -5317,6 +5317,9 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
|
|||||||
if (ok && m_agent && t.lock() == m_user_sync_token && userid == m_agent->get_user_id()) reload_settings();
|
if (ok && m_agent && t.lock() == m_user_sync_token && userid == m_agent->get_user_id()) reload_settings();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
cancelFn = [this]() {
|
||||||
|
return is_closing();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sync_update_thread = Slic3r::create_thread(
|
m_sync_update_thread = Slic3r::create_thread(
|
||||||
@@ -5342,6 +5345,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}, progressFn, cancelFn);
|
}, progressFn, cancelFn);
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << __LINE__ << " get_setting_list2 ret = " << ret << " m_is_closing = " << m_is_closing;
|
||||||
finishFn(ret == 0);
|
finishFn(ret == 0);
|
||||||
|
|
||||||
int count = 0, sync_count = 0;
|
int count = 0, sync_count = 0;
|
||||||
@@ -5386,7 +5390,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
|
|||||||
|
|
||||||
if (total_count == 0) {
|
if (total_count == 0) {
|
||||||
CallAfter([this] {
|
CallAfter([this] {
|
||||||
if (!m_is_closing)
|
if (!is_closing())
|
||||||
plater()->get_notification_manager()->close_notification_of_type(NotificationType::BBLUserPresetExceedLimit);
|
plater()->get_notification_manager()->close_notification_of_type(NotificationType::BBLUserPresetExceedLimit);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -5425,7 +5429,7 @@ void GUI_App::stop_sync_user_preset()
|
|||||||
|
|
||||||
m_user_sync_token.reset();
|
m_user_sync_token.reset();
|
||||||
if (m_sync_update_thread.joinable()) {
|
if (m_sync_update_thread.joinable()) {
|
||||||
if (m_is_closing)
|
if (is_closing())
|
||||||
m_sync_update_thread.join();
|
m_sync_update_thread.join();
|
||||||
else
|
else
|
||||||
m_sync_update_thread.detach();
|
m_sync_update_thread.detach();
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ private:
|
|||||||
std::unique_ptr<Downloader> m_downloader;
|
std::unique_ptr<Downloader> m_downloader;
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
bool m_is_closing {false};
|
std::atomic<bool> m_is_closing {false};
|
||||||
Slic3r::DeviceManager* m_device_manager { nullptr };
|
Slic3r::DeviceManager* m_device_manager { nullptr };
|
||||||
Slic3r::UserManager* m_user_manager { nullptr };
|
Slic3r::UserManager* m_user_manager { nullptr };
|
||||||
Slic3r::TaskManager* m_task_manager { nullptr };
|
Slic3r::TaskManager* m_task_manager { nullptr };
|
||||||
@@ -344,6 +344,9 @@ public:
|
|||||||
bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; }
|
bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; }
|
||||||
bool is_recreating_gui() const { return m_is_recreating_gui; }
|
bool is_recreating_gui() const { return m_is_recreating_gui; }
|
||||||
std::string logo_name() const { return is_editor() ? "OrcaSlicer" : "OrcaSlicer-gcodeviewer"; }
|
std::string logo_name() const { return is_editor() ? "OrcaSlicer" : "OrcaSlicer-gcodeviewer"; }
|
||||||
|
|
||||||
|
bool is_closing() const { return m_is_closing.load(std::memory_order_acquire); }
|
||||||
|
void set_closing(bool closing) { m_is_closing.store(closing, std::memory_order_release); }
|
||||||
|
|
||||||
// SoftFever
|
// SoftFever
|
||||||
bool show_gcode_window() const { return m_show_gcode_window; }
|
bool show_gcode_window() const { return m_show_gcode_window; }
|
||||||
|
|||||||
Reference in New Issue
Block a user