build: clear 53 warnings - discarded values and i18n markers (#15421)

build: clear 53 unused value warnings

49 of them are deliberate i18n markers. L(s) expands to s, so
L("Main Extruder"); is a string literal as a statement and its value is
discarded. The strings have to stay, because the real values come from
printers/*.json at runtime and xgettext cannot scan those. Each block is
now a static const char *const markers[], which uses the values rather
than discarding them. Extraction is unchanged: the xgettext invocation
from scripts/run_gettext.bat gives 76 msgids over the two marker files
before and after, with identical msgid and msgctxt sets.

The other 4 are statements with no effect. AMSItem.cpp:117 and :174
construct and drop a wxColour(255, 255, 255); AMS_TRAY_DEFAULT_COL is
that colour, and the line above already assigns it. UpgradePanel.cpp:865
reads a member and drops it.

wgtDeviceNozzleSelect.cpp:269 writes
if (item; auto ptr = m_nozzle_rack.lock()), which puts the null check in
the init-statement position where its value is discarded, so the check
never runs, and sGetNozzlePosId then dereferences item. Nothing reaches
that today, because the only sender of the event sets itself as the
event object and the dynamic_cast always succeeds. The check now runs.
This commit is contained in:
Kris Austin
2026-08-31 08:55:42 -05:00
committed by GitHub
parent 27e99ca713
commit 36740ffdd8
5 changed files with 35 additions and 27 deletions

View File

@@ -16,24 +16,27 @@ namespace Slic3r
// This block is never executed at runtime. // This block is never executed at runtime.
static void _toolhead_translation_markers() static void _toolhead_translation_markers()
{ {
// Dynamic toolhead display names from JSON config — xgettext cannot scan these // Possible runtime values of tool_head_display_names, marked for extraction.
L("Main Extruder"); L("Main extruder"); L("main extruder"); static const char *const markers[] = {
L("Auxiliary Extruder"); L("Auxiliary extruder"); L("auxiliary extruder"); L("Main Extruder"), L("Main extruder"), L("main extruder"),
L("Left Extruder"); L("Left extruder"); L("left extruder"); L("Auxiliary Extruder"), L("Auxiliary extruder"), L("auxiliary extruder"),
L("Right Extruder"); L("Right extruder"); L("right extruder"); L("Left Extruder"), L("Left extruder"), L("left extruder"),
L("Main Nozzle"); L("Main nozzle"); L("main nozzle"); L("Right Extruder"), L("Right extruder"), L("right extruder"),
L("Auxiliary Nozzle"); L("Auxiliary nozzle"); L("auxiliary nozzle"); L("Main Nozzle"), L("Main nozzle"), L("main nozzle"),
L("Left Nozzle"); L("Left nozzle"); L("left nozzle"); L("Auxiliary Nozzle"), L("Auxiliary nozzle"), L("auxiliary nozzle"),
L("Right Nozzle"); L("Right nozzle"); L("right nozzle"); L("Left Nozzle"), L("Left nozzle"), L("left nozzle"),
L("Main Hotend"); L("Main hotend"); L("main hotend"); L("Right Nozzle"), L("Right nozzle"), L("right nozzle"),
L("Auxiliary Hotend"); L("Auxiliary hotend"); L("auxiliary hotend"); L("Main Hotend"), L("Main hotend"), L("main hotend"),
L("Left Hotend"); L("Left hotend"); L("left hotend"); L("Auxiliary Hotend"), L("Auxiliary hotend"), L("auxiliary hotend"),
L("Right Hotend"); L("Right hotend"); L("right hotend"); L("Left Hotend"), L("Left hotend"), L("left hotend"),
// standalone position words (short_name=true runtime results) L("Right Hotend"), L("Right hotend"), L("right hotend"),
L("main"); L("auxiliary"); // standalone position words (short_name=true runtime results)
L("Main"); L("Auxiliary"); L("main"), L("auxiliary"),
L("left"); L("right"); L("Main"), L("Auxiliary"),
L("Left"); L("Right"); L("left"), L("right"),
L("Left"), L("Right"),
};
(void) markers;
} }
std::string DevPrinterConfigUtil::m_resource_file_path = ""; std::string DevPrinterConfigUtil::m_resource_file_path = "";

View File

@@ -266,7 +266,7 @@ void wgtDeviceNozzleRackSelect::OnNozzleItemSelected(wxCommandEvent &evt)
} }
auto *item = dynamic_cast<wgtDeviceNozzleRackNozzleItem *>(evt.GetEventObject()); auto *item = dynamic_cast<wgtDeviceNozzleRackNozzleItem *>(evt.GetEventObject());
if (item; auto ptr = m_nozzle_rack.lock()) { if (auto ptr = m_nozzle_rack.lock(); item && ptr) {
int to_select_pos_id = sGetNozzlePosId(item, m_toolhead_nozzle_l, m_toolhead_nozzle_r); int to_select_pos_id = sGetNozzlePosId(item, m_toolhead_nozzle_l, m_toolhead_nozzle_r);
if (to_select_pos_id > -1 && to_select_pos_id != GetSelectedNozzlePosID()) { if (to_select_pos_id > -1 && to_select_pos_id != GetSelectedNozzlePosID()) {
SetSelectedNozzle(ptr->GetNozzleSystem()->GetNozzleByPosId(to_select_pos_id)); SetSelectedNozzle(ptr->GetNozzleSystem()->GetNozzleByPosId(to_select_pos_id));

View File

@@ -862,7 +862,6 @@ void MachineInfoPanel::update_ams_ext(MachineObject *obj)
if (new_extra_ams_ver != obj->new_ver_list.end()) if (new_extra_ams_ver != obj->new_ver_list.end())
has_new_version = true; has_new_version = true;
extra_ams_it->second.sw_new_ver;
if (has_new_version) { if (has_new_version) {
m_extra_ams_panel->m_ams_new_version_img->Show(); m_extra_ams_panel->m_ams_new_version_img->Show();
ver_text = new_extra_ams_ver->second.sw_ver; ver_text = new_extra_ams_ver->second.sw_ver;

View File

@@ -114,7 +114,6 @@ bool AMSinfo::parse_ams_info(MachineObject *obj, DevAms *ams, bool remain_flag,
info.ctype = 0; info.ctype = 0;
info.material_colour = AMS_TRAY_DEFAULT_COL; info.material_colour = AMS_TRAY_DEFAULT_COL;
info.material_state = AMSCanType::AMS_CAN_TYPE_THIRDBRAND; info.material_state = AMSCanType::AMS_CAN_TYPE_THIRDBRAND;
wxColour(255, 255, 255);
} }
if (it->second->is_tray_info_ready() && obj->cali_version >= 0) { if (it->second->is_tray_info_ready() && obj->cali_version >= 0) {
@@ -171,7 +170,6 @@ void AMSinfo::parse_ext_info(MachineObject* obj, DevAmsTray tray) {
info.filament_id = ""; info.filament_id = "";
info.ctype = 0; info.ctype = 0;
info.material_colour = AMS_TRAY_DEFAULT_COL; info.material_colour = AMS_TRAY_DEFAULT_COL;
wxColour(255, 255, 255);
} }
info.material_state = AMSCanType::AMS_CAN_TYPE_VIRTUAL; info.material_state = AMSCanType::AMS_CAN_TYPE_VIRTUAL;
if (tray.is_tray_info_ready() && obj->cali_version >= 0) { if (tray.is_tray_info_ready() && obj->cali_version >= 0) {

View File

@@ -1014,8 +1014,12 @@ void FanControlPopupNew::init_names(MachineObject* obj) {
if (obj) { if (obj) {
const std::string& special_cooling_text = DevPrinterConfigUtil::get_fan_text(obj->printer_type, "special_cooling_text"); const std::string& special_cooling_text = DevPrinterConfigUtil::get_fan_text(obj->printer_type, "special_cooling_text");
if (!special_cooling_text.empty()) { if (!special_cooling_text.empty()) {
L("Cooling mode is suitable for printing PLA/PETG/TPU materials."); //some potential text, add i18n flags // Possible runtime values of special_cooling_text, marked for extraction.
L("Cooling mode is suitable for printing PLA/PETG/TPU materials and filters the chamber air."); static const char *const markers[] = {
L("Cooling mode is suitable for printing PLA/PETG/TPU materials."),
L("Cooling mode is suitable for printing PLA/PETG/TPU materials and filters the chamber air."),
};
(void) markers;
label_text[AIR_DUCT::AIR_DUCT_COOLING_FILT] = _L(special_cooling_text); label_text[AIR_DUCT::AIR_DUCT_COOLING_FILT] = _L(special_cooling_text);
} }
} }
@@ -1028,9 +1032,13 @@ wxString FanControlPopupNew::get_fan_func_name(int mode, int submode, AIR_FUN fu
const std::string& func_text = DevPrinterConfigUtil::get_fan_text(m_obj->printer_type, mode, (int)func, submode); const std::string& func_text = DevPrinterConfigUtil::get_fan_text(m_obj->printer_type, mode, (int)func, submode);
if (!func_text.empty()) if (!func_text.empty())
{ {
L_CONTEXT("Right(Aux)", "air_duct"); // Possible runtime values of func_text, marked for extraction.
L_CONTEXT("Right(Filter)", "air_duct"); static const char *const markers[] = {
L_CONTEXT("Left(Aux)", "air_duct"); L_CONTEXT("Right(Aux)", "air_duct"),
L_CONTEXT("Right(Filter)", "air_duct"),
L_CONTEXT("Left(Aux)", "air_duct"),
};
(void) markers;
return _L_CONTEXT(func_text, "air_duct"); return _L_CONTEXT(func_text, "air_duct");
} }
} }