build: clear 237 warnings - unused lambda captures (#15417)

* build: enable /Zc:lambda for MSVC

MSVC keeps its legacy lambda processor under /std:c++17, which rejects
reading a constexpr constant inside a lambda that does not capture it
(C3493). No other compiler requires that capture, and clang reports it as
an unused one, so the two cannot both be satisfied without the flag.

/Zc:lambda selects the conforming lambda parser that clang and GCC
already use. It is implied by /std:c++20 and /permissive-, so it is only
needed while we are on C++17. clang-cl is conforming already and does not
take the flag.

It requires VS2019 16.8, so build_release_vs.bat now says 16.8+.

* build: clear 237 unused lambda capture warnings

236 captures across 81 files, 142 of them `this`. Removing an unused
capture changes no behavior; clang does not report a capture whose type
has a non-trivial destructor, so nothing held only to extend an object's
lifetime is in this set.

Nine of them are the second half of the warning, "is not required to be
captured for this use", where the capture is a const or constexpr value
the body does read. Those depend on the /Zc:lambda change in the previous
commit. One of them, in FillRectilinear.cpp, had been worked around with
an #ifndef __APPLE__ guard around the capture list, which is now gone.

GUI_ObjectTableSettings.cpp captured its reset button only to read it
inside #ifdef __WXOSX_MAC__. That branch now takes the button from the
event it is already handling.

* build: fail configure on MSVC older than 19.28 instead of dropping /Zc:lambda

cl.exe answers an unrecognized /Zc: sub-option with warning D9002 and keeps
going, so on VS2019 before 16.8 the flag is silently ignored and the build
instead dies with C3493 in FillRectilinear.cpp, nowhere near the cause.

* fix: delete three locals that are now unused

Their only remaining use was the lambda capture this branch removed. The
Clang builds set -Wno-unused-variable, so the build never flagged them.

---------

Co-authored-by: Rodrigo Faselli <162915171+RF47@users.noreply.github.com>
This commit is contained in:
Kris Austin
2026-09-02 07:38:05 -03:00
committed by GitHub
co-authored by Rodrigo Faselli
parent e523acc164
commit 1749c293a6
83 changed files with 226 additions and 217 deletions
+28 -29
View File
@@ -1340,7 +1340,7 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
if (index >= 0) label_flow->SetMinSize({FromDIP(80), -1});
auto combo_flow = new ComboBox(this, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY);
combo_flow->GetDropDown().SetUseContentWidth(true);
combo_flow->Bind(wxEVT_COMBOBOX, [this, index, combo_flow](wxCommandEvent &evt) {
combo_flow->Bind(wxEVT_COMBOBOX, [index, combo_flow](wxCommandEvent &evt) {
auto printer_tab = dynamic_cast<TabPrinter *>(wxGetApp().get_tab(Preset::TYPE_PRINTER));
NozzleVolumeType volume_type = NozzleVolumeType(intptr_t(combo_flow->GetClientData(evt.GetInt())));
printer_tab->set_extruder_volume_type(index, volume_type);
@@ -1400,7 +1400,7 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
btn_up = new ScalableButton(this, wxID_ANY, "page_up", "", {FromDIP(14), FromDIP(14)}, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 14);
btn_up->SetBackgroundColour(*wxWHITE);
btn_up->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this, index](auto &evt) {
btn_up->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](auto &evt) {
if (page_cur > 0)
--page_cur;
update_ams();
@@ -1408,7 +1408,7 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
btn_up->Hide();
btn_down = new ScalableButton(this, wxID_ANY, "page_down", "", {FromDIP(14), FromDIP(14)}, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 14);
btn_down->SetBackgroundColour(*wxWHITE);
btn_down->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this, index](auto &evt) {
btn_down->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](auto &evt) {
if (page_cur + 1 < page_num)
++page_cur;
update_ams();
@@ -2025,7 +2025,7 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material, bool is_man
if (!this->plater)
return false;
this->plater->update_objects_position_when_select_preset([&obj, machine_preset]() {
this->plater->update_objects_position_when_select_preset([machine_preset]() {
Tab *printer_tab = GUI::wxGetApp().get_tab(Preset::Type::TYPE_PRINTER);
printer_tab->select_preset(machine_preset->name);
});
@@ -2170,7 +2170,7 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material, bool is_man
void Sidebar::priv::update_sync_status(const MachineObject *obj)
{
StateColor not_synced_colour(std::pair<wxColour, int>(wxColour("#009688"), StateColor::Normal));
auto clear_all_sync_status = [this, &not_synced_colour]() {
auto clear_all_sync_status = [this]() {
panel_printer_preset->ShowBadge(false);
panel_printer_bed->ShowBadge(false);
panel_nozzle_dia->ShowBadge(false); // ORCA add support for nozzle sync
@@ -2474,7 +2474,7 @@ Sidebar::Sidebar(Plater *parent)
p->m_printer_icon = new ScalableButton(p->m_panel_printer_title, wxID_ANY, "printer");
p->m_text_printer_settings = new Label(p->m_panel_printer_title, _L("Printer"), LB_PROPAGATE_MOUSE_EVENT | wxST_ELLIPSIZE_END);
p->m_printer_icon->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
p->m_printer_icon->Bind(wxEVT_BUTTON, [](wxCommandEvent& e) {
//auto wizard_t = new ConfigWizard(wxGetApp().mainframe);
//wizard_t->run(ConfigWizard::RR_USER, ConfigWizard::SP_CUSTOM);
});
@@ -2495,7 +2495,7 @@ Sidebar::Sidebar(Plater *parent)
});
p->m_printer_setting = new ScalableButton(p->m_panel_printer_title, wxID_ANY, "settings");
p->m_printer_setting->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
p->m_printer_setting->Bind(wxEVT_BUTTON, [](wxCommandEvent &e) {
// p->editing_filament = -1;
// wxGetApp().params_dialog()->Popup();
// wxGetApp().get_tab(Preset::TYPE_FILAMENT)->restore_last_select_item();
@@ -2610,8 +2610,8 @@ Sidebar::Sidebar(Plater *parent)
p->image_printer->SetBackgroundColour(bg_color);
p->combo_printer->SetBackgroundColour(bg_color); // paints margins instead combo background
};
p->combo_printer->Bind(wxEVT_SET_FOCUS, [this, printer_focus_bg](auto& e) {printer_focus_bg(true ); e.Skip();});
p->combo_printer->Bind(wxEVT_KILL_FOCUS, [this, printer_focus_bg](auto& e) {printer_focus_bg(false); e.Skip();});
p->combo_printer->Bind(wxEVT_SET_FOCUS, [printer_focus_bg](auto& e) {printer_focus_bg(true ); e.Skip();});
p->combo_printer->Bind(wxEVT_KILL_FOCUS, [printer_focus_bg](auto& e) {printer_focus_bg(false); e.Skip();});
/* ORCA This part moved to titlebar
p->btn_connect_printer = new ScalableButton(p->panel_printer_preset, wxID_ANY, "monitor_signal_strong");
@@ -2688,8 +2688,8 @@ Sidebar::Sidebar(Plater *parent)
p->label_nozzle_type->SetBackgroundColour(bg_color);
p->combo_nozzle_dia->SetBackgroundColour(bg_color); // paints margins instead combo background
};
p->combo_nozzle_dia->Bind(wxEVT_SET_FOCUS, [this, nozzle_focus_bg](auto& e) {nozzle_focus_bg(true ); e.Skip();});
p->combo_nozzle_dia->Bind(wxEVT_KILL_FOCUS, [this, nozzle_focus_bg](auto& e) {nozzle_focus_bg(false); e.Skip();});
p->combo_nozzle_dia->Bind(wxEVT_SET_FOCUS, [nozzle_focus_bg](auto& e) {nozzle_focus_bg(true ); e.Skip();});
p->combo_nozzle_dia->Bind(wxEVT_KILL_FOCUS, [nozzle_focus_bg](auto& e) {nozzle_focus_bg(false); e.Skip();});
p->label_nozzle_type = new Label(p->panel_nozzle_dia, "Brass", LB_PROPAGATE_MOUSE_EVENT | wxST_ELLIPSIZE_END | wxALIGN_CENTRE_HORIZONTAL);
p->label_nozzle_type->SetFont(Label::Body_10);
@@ -2763,8 +2763,8 @@ Sidebar::Sidebar(Plater *parent)
p->image_printer_bed->SetBackgroundColour(bg_color);
p->combo_printer_bed->SetBackgroundColour(bg_color); // paints margins instead combo background
};
p->combo_printer_bed->Bind(wxEVT_SET_FOCUS, [this, bed_focus_bg](auto& e) {bed_focus_bg(true ); e.Skip();});
p->combo_printer_bed->Bind(wxEVT_KILL_FOCUS, [this, bed_focus_bg](auto& e) {bed_focus_bg(false); e.Skip();});
p->combo_printer_bed->Bind(wxEVT_SET_FOCUS, [bed_focus_bg](auto& e) {bed_focus_bg(true ); e.Skip();});
p->combo_printer_bed->Bind(wxEVT_KILL_FOCUS, [bed_focus_bg](auto& e) {bed_focus_bg(false); e.Skip();});
// highlight border on hover
auto printer_bed_hovered = std::make_shared<std::unordered_set<wxWindow*>>();
@@ -2978,7 +2978,7 @@ Sidebar::Sidebar(Plater *parent)
ScalableButton* add_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "add_filament");
add_btn->SetToolTip(_L("Add one filament"));
add_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent& e){
add_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e){
add_filament();
update_filaments_counter();
});
@@ -2988,7 +2988,7 @@ Sidebar::Sidebar(Plater *parent)
ScalableButton* del_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "delete_filament");
del_btn->SetToolTip(_L("Remove last filament"));
del_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
del_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
delete_filament();
update_filaments_counter();
});
@@ -3002,7 +3002,7 @@ Sidebar::Sidebar(Plater *parent)
ams_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, false, 16); // ORCA match icon size with other icons as 16x16
ams_btn->SetToolTip(_L("Synchronize filament list from AMS"));
ams_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
ams_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
sync_ams_list();
});
@@ -3682,7 +3682,7 @@ void Sidebar::update_presets(Preset::Type preset_type)
extruder.combo_flow->SetSelection(select);
};
auto update_extruder_diameter = [&diameters, &diameter, &nozzle_diameter](int extruder_index,ExtruderGroup & extruder) {
auto update_extruder_diameter = [&diameters, &nozzle_diameter](int extruder_index,ExtruderGroup & extruder) {
extruder.combo_diameter->Clear();
int select = -1;
// ORCA get the actual nozzle diameter from printer config
@@ -7497,7 +7497,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
// Keep tracking the current sidebar size, by storing it using `best_size`, which will be stored
// in the config and re-applied when the app is opened again.
this->sidebar->Bind(wxEVT_IDLE, [&sidebar, this](wxIdleEvent& e) {
this->sidebar->Bind(wxEVT_IDLE, [&sidebar](wxIdleEvent& e) {
if (sidebar.IsShown() && sidebar.IsDocked() && sidebar.rect.GetWidth() > 0) {
sidebar.BestSize(sidebar.rect.GetWidth(), sidebar.best_size.GetHeight());
}
@@ -7796,8 +7796,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
wxGetApp().removable_drive_manager()->init(this->q);
#ifdef _WIN32
//Trigger enumeration of removable media on Win32 notification.
this->q->Bind(EVT_VOLUME_ATTACHED, [this](VolumeAttachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
this->q->Bind(EVT_VOLUME_DETACHED, [this](VolumeDetachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
this->q->Bind(EVT_VOLUME_ATTACHED, [](VolumeAttachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
this->q->Bind(EVT_VOLUME_DETACHED, [](VolumeDetachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
#endif /* _WIN32 */
}
@@ -8354,7 +8354,6 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
const float LOAD_MODEL_RATIO = 0.9;
for (size_t i = 0; i < input_files.size(); ++i) {
int file_percent = 0;
#ifdef _WIN32
auto path = input_files[i];
@@ -8403,7 +8402,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
q->skip_thumbnail_invalid = true;
model = Slic3r::Model::read_from_archive(path.string(), &config_loaded, &config_substitutions, en_3mf_file_type, strategy, &plate_data, &project_presets,
&file_version,
[this, &dlg, real_filename, &progress_percent, &file_percent, stage_percent, INPUT_FILES_RATIO, total_files, i,
[&dlg, real_filename, &progress_percent, stage_percent, INPUT_FILES_RATIO, total_files, i,
&is_user_cancel](int import_stage, int current, int total, bool &cancel) {
bool cont = true;
float percent_float = (100.0f * (float)i / (float)total_files) + INPUT_FILES_RATIO * ((float)stage_percent[import_stage] + (float)current * (float)(stage_percent[import_stage + 1] - stage_percent[import_stage]) /(float) total) / (float)total_files;
@@ -8986,7 +8985,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
Semver file_version;
//ObjImportColorFn obj_color_fun=nullptr;
auto obj_color_fun = [this, &path](ObjDialogInOut &in_out) {
auto obj_color_fun = [&path](ObjDialogInOut &in_out) {
if (!boost::iends_with(path.string(), ".obj")) { return; }
const std::vector<std::string> extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config();
@@ -9003,7 +9002,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
if (angle <= 0) angle = 0.5;
bool split_compound = wxGetApp().app_config->get_bool("is_split_compound");
model = Slic3r::Model:: read_from_step(path.string(), strategy,
[this, &dlg, real_filename, &progress_percent, &file_percent, step_percent, INPUT_FILES_RATIO, total_files, i](int load_stage, int current, int total, bool &cancel)
[&dlg, real_filename, &progress_percent, step_percent, INPUT_FILES_RATIO, total_files, i](int load_stage, int current, int total, bool &cancel)
{
bool cont = true;
float percent_float = (100.0f * (float)i / (float)total_files) + INPUT_FILES_RATIO * ((float)step_percent[load_stage] + (float)current * (float)(step_percent[load_stage + 1] - step_percent[load_stage]) / (float)total) / (float)total_files;
@@ -9027,7 +9026,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
}
}
},
[this, &path, &is_user_cancel, &linear, &angle, &split_compound](Slic3r::Step& file, double& linear_value, double& angle_value, bool& is_split)-> int {
[&is_user_cancel, &linear, &angle, &split_compound](Slic3r::Step& file, double& linear_value, double& angle_value, bool& is_split)-> int {
if (wxGetApp().app_config->get_bool("enable_step_mesh_setting")) {
StepMeshDialog mesh_dlg(nullptr, file, linear, angle);
if (mesh_dlg.ShowModal() == wxID_OK) {
@@ -9048,7 +9047,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
}else {
model = Slic3r::Model:: read_from_file(
path.string(), nullptr, nullptr, strategy, &plate_data, &project_presets, &is_xxx, &file_version, nullptr,
[this, &dlg, real_filename, &progress_percent, &file_percent, INPUT_FILES_RATIO, total_files, i, &designer_model_id, &designer_country_code](int current, int total, bool &cancel, std::string &mode_id, std::string &code)
[&dlg, real_filename, &progress_percent, INPUT_FILES_RATIO, total_files, i, &designer_model_id, &designer_country_code](int current, int total, bool &cancel, std::string &mode_id, std::string &code)
{
designer_model_id = mode_id;
designer_country_code = code;
@@ -11294,7 +11293,7 @@ void Plater::priv::reload_from_disk()
// load one file at a time
for (size_t i = 0; i < input_paths.size(); ++i) {
const auto& path = input_paths[i].string();
auto obj_color_fun = [this, &path](ObjDialogInOut &in_out) {
auto obj_color_fun = [&path](ObjDialogInOut &in_out) {
if (!boost::iends_with(path, ".obj")) { return; }
const std::vector<std::string> extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config();
ObjColorDialog color_dlg(nullptr, in_out, extruder_colours, Sidebar::should_show_SEMM_buttons());
@@ -15265,7 +15264,7 @@ void Plater::import_model_id(wxString download_info)
p->project.reset();
/* prepare project and profile */
boost::thread import_thread = Slic3r::create_thread([&percent, &cont, &cancel, &retry_count, max_retries, &msg, &target_path, &download_ok, download_url, &filename] {
boost::thread import_thread = Slic3r::create_thread([&percent, &cont, &retry_count, &msg, &target_path, &download_ok, download_url, &filename] {
// Orca: NetworkAgent is not needed and only prevents this from running
// NetworkAgent* m_agent = Slic3r::GUI::wxGetApp().getAgent();
@@ -15372,7 +15371,7 @@ void Plater::import_model_id(wxString download_info)
msg = wxString::Format(_L("Project downloaded %d%%"), percent);
}
})
.on_error([&msg, &cont, &retry_count, max_retries](std::string body, std::string error, unsigned http_status) {
.on_error([&msg, &cont, &retry_count](std::string body, std::string error, unsigned http_status) {
(void)body;
BOOST_LOG_TRIVIAL(error) << format("Error getting: `%1%`: HTTP %2%, %3%",
body,