From e7d6f5e6c062c211d6d0fada681eab43d694679d Mon Sep 17 00:00:00 2001 From: Kris Austin Date: Tue, 6 Oct 2026 07:55:25 -0500 Subject: [PATCH] fix: crash in LAN mode when the printer type is not known yet (#16191) * fix: crash in LAN mode when the printer type is not known yet InputIpAddressDialog::set_machine_obj() built the help image name from the printer config with no fallback. If the printer type is empty or unknown, for example before the first push_all arrives on a flaky LAN link, the lookup returns "" and create_scaled_bitmap("_en") throws. The dialog is opened by the "LAN Connection Failed" handlers in MediaPlayCtrl and MediaFilePanel, where nothing catches the exception, so the app crashes. Use input_access_code_x1 when there is no image, and the _cn image for zh_CN, the same as ConnectPrinterDialog::init_bitmap(). Ported from Bambu Studio 52ca2ec5d1. * fix: return an empty bitmap for an empty icon name create_scaled_bitmap() threw when a caller passed an empty name. That happens when a printer config lookup has no entry, for example in AMSSetting::update_ams_img() for a printer type with no AMS image. Log an error and return wxNullBitmap instead. Ported from Bambu Studio 52ca2ec5d1. --- src/slic3r/GUI/ReleaseNote.cpp | 5 ++++- src/slic3r/GUI/wxExtensions.cpp | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 9a0bc54b6e..67dc80ca6d 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1816,7 +1816,10 @@ void InputIpAddressDialog::set_machine_obj(MachineObject* obj) m_input_printer_name->GetTextCtrl()->SetLabelText(m_obj->get_dev_name()); std::string img_str = DevPrinterConfigUtil::get_printer_connect_help_img(m_obj->printer_type); - auto diagram_bmp = create_scaled_bitmap(img_str + "_en", this, 198); + if (img_str.empty()) { img_str = "input_access_code_x1"; } + + std::string language = wxGetApp().app_config->get("language"); + auto diagram_bmp = create_scaled_bitmap(img_str + (language == "zh_CN" ? "_cn" : "_en"), this, 198); m_img_help->SetBitmap(diagram_bmp); diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 5d38e87f4d..5babf843bc 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -456,6 +456,13 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in, const vector& array_new_color/* = vector*/)//used for semi transparent material) { static Slic3r::GUI::BitmapCache cache; + + // An empty name means the caller's icon lookup failed + if (bmp_name_in.empty() || bmp_name_in == ".png") { + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": empty bitmap name"; + return wxNullBitmap; + } + if (bitmap2) { return create_scaled_bitmap2(bmp_name_in, cache, win, px_cnt, grayscale, resize, array_new_color); }