Fix an issue that sync ams btn is not show/hide after printer agent changes

This commit is contained in:
SoftFever 2026-02-02 12:20:09 +08:00
parent 86421c6378
commit d817a4d5d4
2 changed files with 16 additions and 8 deletions

View file

@ -3498,11 +3498,12 @@ void GUI_App::switch_printer_agent()
current_agent_id = m_agent->get_printer_agent()->get_agent_info().id;
if (current_agent_id != effective_agent_id) {
std::string log_dir = data_dir();
std::string log_dir = data_dir();
std::shared_ptr<ICloudServiceAgent> cloud_agent = m_agent->get_cloud_agent();
// Create new printer agent via registry
std::shared_ptr<IPrinterAgent> new_printer_agent = NetworkAgentFactory::create_printer_agent_by_id(effective_agent_id, cloud_agent,
log_dir);
std::shared_ptr<IPrinterAgent> new_printer_agent =
NetworkAgentFactory::create_printer_agent_by_id(effective_agent_id, cloud_agent, log_dir);
if (!new_printer_agent) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": failed to create agent '" << effective_agent_id << "', keeping current agent";
@ -3511,11 +3512,13 @@ void GUI_App::switch_printer_agent()
// Swap the agent
m_agent->set_printer_agent(new_printer_agent);
}
// Auto-switch MachineObject
select_machine(effective_agent_id);
sidebar().update_all_preset_comboboxes();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": printer agent switched to " << effective_agent_id;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": printer agent switched to " << effective_agent_id;
}
// Auto-switch MachineObject (runs even if agent IDs match)
select_machine(effective_agent_id);
}
void GUI_App::select_machine(const std::string& agent_id)

View file

@ -820,8 +820,13 @@ void PhysicalPrinterDialog::check_host_key_valid()
void PhysicalPrinterDialog::OnOK(wxEvent& event)
{
wxGetApp().get_tab(Preset::TYPE_PRINTER)->save_preset("", false, false, true, m_preset_name );
wxGetApp().get_tab(Preset::TYPE_PRINTER)->save_preset("", false, false, true, m_preset_name);
event.Skip();
// Defer printer agent switch to ensure preset save completes first
wxGetApp().CallAfter([] {
wxGetApp().switch_printer_agent();
});
}
}} // namespace Slic3r::GUI