mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-22 20:55:16 +00:00
Fixes a possible null dereference in DeviceManager::check_pushing() when the selected machine is missing or stale during timer refresh. (#13802)
* Fix selected-machine null deref in device pushing check
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
#include "DevManager.h"
|
#include "DevManager.h"
|
||||||
#include "DevUtil.h"
|
#include "DevUtil.h"
|
||||||
|
|
||||||
@@ -151,11 +154,15 @@ namespace Slic3r
|
|||||||
{
|
{
|
||||||
keep_alive();
|
keep_alive();
|
||||||
MachineObject* obj = this->get_selected_machine();
|
MachineObject* obj = this->get_selected_machine();
|
||||||
|
if (!obj) {
|
||||||
|
BOOST_LOG_TRIVIAL(warning) << "DeviceManager::check_pushing selected machine not found";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::chrono::system_clock::time_point start = std::chrono::system_clock::now();
|
std::chrono::system_clock::time_point start = std::chrono::system_clock::now();
|
||||||
auto internal = std::chrono::duration_cast<std::chrono::milliseconds>(start - obj->last_update_time);
|
auto internal = std::chrono::duration_cast<std::chrono::milliseconds>(start - obj->last_update_time);
|
||||||
|
|
||||||
if (obj && !obj->is_support_mqtt_alive)
|
if (!obj->is_support_mqtt_alive)
|
||||||
{
|
{
|
||||||
if (internal.count() > TIMEOUT_FOR_STRAT && internal.count() < 1000 * 60 * 60 * 300)
|
if (internal.count() > TIMEOUT_FOR_STRAT && internal.count() < 1000 * 60 * 60 * 300)
|
||||||
{
|
{
|
||||||
@@ -916,18 +923,33 @@ namespace Slic3r
|
|||||||
const auto cloud_provider = Slic3r::GUI::wxGetApp().get_printer_cloud_provider();
|
const auto cloud_provider = Slic3r::GUI::wxGetApp().get_printer_cloud_provider();
|
||||||
if (Slic3r::GUI::wxGetApp().is_user_login(cloud_provider))
|
if (Slic3r::GUI::wxGetApp().is_user_login(cloud_provider))
|
||||||
{
|
{
|
||||||
m_manager->check_pushing();
|
try {
|
||||||
try
|
m_manager->check_pushing();
|
||||||
{
|
} catch (const std::exception& e) {
|
||||||
agent->refresh_connection(cloud_provider);
|
BOOST_LOG_TRIVIAL(error) << "DeviceManagerRefresher::on_timer check_pushing exception="
|
||||||
|
<< e.what();
|
||||||
|
} catch (...) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "DeviceManagerRefresher::on_timer check_pushing unknown exception";
|
||||||
}
|
}
|
||||||
catch (...)
|
|
||||||
{
|
try {
|
||||||
;
|
agent->refresh_connection(cloud_provider);
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "DeviceManagerRefresher::on_timer refresh_connection exception="
|
||||||
|
<< e.what();
|
||||||
|
} catch (...) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "DeviceManagerRefresher::on_timer refresh_connection unknown exception";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// certificate
|
// certificate
|
||||||
agent->install_device_cert(obj->get_dev_id(), obj->is_lan_mode_printer());
|
try {
|
||||||
|
agent->install_device_cert(obj->get_dev_id(), obj->is_lan_mode_printer());
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "DeviceManagerRefresher::on_timer install_device_cert exception="
|
||||||
|
<< e.what();
|
||||||
|
} catch (...) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "DeviceManagerRefresher::on_timer install_device_cert unknown exception";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user