ENH: fix crash in parse_sdp_message

Change-Id: I4885024f5126212050aa2b199bf27adc1899c7c4
This commit is contained in:
Stone Li 2022-08-03 21:04:04 +08:00 committed by Lane.Wei
parent e80c6f8935
commit aa5ecd52d0
1 changed files with 21 additions and 19 deletions

View File

@ -1066,10 +1066,10 @@ 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) {
return;
}
GUI::wxGetApp().CallAfter([this, json_str] { GUI::wxGetApp().CallAfter([this, json_str] {
if (m_is_closing) {
return;
}
if (m_device_manager) { if (m_device_manager) {
m_device_manager->on_machine_alive(json_str); m_device_manager->on_machine_alive(json_str);
} }
@ -1424,10 +1424,10 @@ 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) {
return;
}
GUI::wxGetApp().CallAfter([this, json_str] { GUI::wxGetApp().CallAfter([this, json_str] {
if (m_is_closing) {
return;
}
if (m_device_manager) { if (m_device_manager) {
m_device_manager->on_machine_alive(json_str); m_device_manager->on_machine_alive(json_str);
} }
@ -1493,20 +1493,20 @@ void GUI_App::init_networking_callbacks()
}); });
m_agent->set_on_server_connected_fn([this]() { m_agent->set_on_server_connected_fn([this]() {
if (m_is_closing) {
return;
}
GUI::wxGetApp().CallAfter([this] { GUI::wxGetApp().CallAfter([this] {
if (m_is_closing) {
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());
}); });
}); });
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) {
return;
}
GUI::wxGetApp().CallAfter([this, dev_id] { GUI::wxGetApp().CallAfter([this, dev_id] {
if (m_is_closing) {
return;
}
/* request_pushing */ /* request_pushing */
MachineObject* obj = m_device_manager->get_my_machine(dev_id); MachineObject* obj = m_device_manager->get_my_machine(dev_id);
if (obj) { if (obj) {
@ -1525,6 +1525,9 @@ 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) {
return;
}
CallAfter([this, state, dev_id, msg] { CallAfter([this, state, dev_id, msg] {
if (m_is_closing) { if (m_is_closing) {
return; return;
@ -1556,10 +1559,10 @@ 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) {
return;
}
CallAfter([this, dev_id, msg] { CallAfter([this, dev_id, msg] {
if (m_is_closing) {
return;
}
MachineObject* obj = this->m_device_manager->get_user_machine(dev_id); MachineObject* obj = this->m_device_manager->get_user_machine(dev_id);
if (obj) { if (obj) {
obj->parse_json(msg); obj->parse_json(msg);
@ -1574,11 +1577,10 @@ 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 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) {
return;
}
CallAfter([this, dev_id, msg] { CallAfter([this, dev_id, msg] {
if (m_is_closing) {
return;
}
MachineObject* obj = m_device_manager->get_my_machine(dev_id); MachineObject* obj = m_device_manager->get_my_machine(dev_id);
if (!obj) { if (!obj) {
obj = m_device_manager->get_local_machine(dev_id); obj = m_device_manager->get_local_machine(dev_id);