Fix filament sync targeting wrong printer after switching printer presets (#12506) (#14587)

For non-BBL host printers (Moonraker/Klipper, Qidi, Snapmaker, Creality), switch_printer_agent() only re-selected the machine when the agent type changed. Switching between two printer presets that use the same agent left the selected machine and the agent's cached device_info pointing at the previously active preset's host, so filament sync kept hitting the old printer.

Re-select the machine when the agent type is unchanged but the target host differs, so the selected machine and device_info always follow the active printer preset.

Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
This commit is contained in:
bobomb
2026-07-13 03:08:53 -04:00
committed by GitHub
parent 5a53d2eb88
commit 4eb9a85a49

View File

@@ -3633,8 +3633,24 @@ void GUI_App::switch_printer_agent()
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": printer agent switched to " << effective_agent_id;
// Auto-switch MachineObject
// Auto-switch MachineObject (new agent has empty device_info, so always re-select)
select_machine(effective_agent_id);
} else if (effective_agent_id != BBL_PRINTER_AGENT_ID) {
// Orca: the agent type is unchanged (e.g. switching between two Moonraker/Klipper
// printer presets), so the selected machine and the agent's cached device_info still
// point at the previously active printer preset. Re-select the machine when the new
// preset targets a different host, otherwise filament sync keeps hitting the old
// printer. (#12506)
if (m_device_manager && preset_bundle) {
const DynamicPrintConfig& cfg = preset_bundle->printers.get_edited_preset().config;
const std::string print_host = cfg.opt_string("print_host");
if (!print_host.empty()) {
const std::string dev_id = MachineObject::dev_id_from_address(print_host, cfg.opt_string("printhost_port"));
MachineObject* sel = m_device_manager->get_selected_machine();
if (!sel || sel->get_dev_id() != dev_id)
select_machine(effective_agent_id);
}
}
}
}