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
+10 -10
View File
@@ -9236,7 +9236,7 @@ void GLCanvas3D::_render_imgui_select_plate_toolbar()
ImVec2 size = ImVec2(button_width, button_height);
ImVec2 end_pos = ImVec2(start_pos.x + size.x, start_pos.y + size.y);
// ORCA show additional information depends on state
auto draw_info_btn = [end_pos, f_scale, margin, window_bg](std::string str, ImVec4 bg_color, ImVec4 fg_color){
auto draw_info_btn = [end_pos, f_scale, margin](std::string str, ImVec4 bg_color, ImVec4 fg_color){
GImGui->FontSize = 15.0f * f_scale;
ImVec2 txt_slice_sz = ImGui::CalcTextSize(str.c_str());
ImVec2 btn_pad = ImVec2(8.f, 1.f) * f_scale;
@@ -9492,7 +9492,7 @@ void GLCanvas3D::_render_canvas_toolbar()
Plater* p = wxGetApp().plater();
AppConfig* cfg = wxGetApp().app_config;
auto create_menu_item = [this, sc](
auto create_menu_item = [sc](
const std::string& name,
bool enable,
bool condition,
@@ -9509,7 +9509,7 @@ void GLCanvas3D::_render_canvas_toolbar()
create_menu_item( _utf8(L("3D Navigator")),
m_canvas_type != ECanvasType::CanvasAssembleView, // not work on assembly
wxGetApp().show_3d_navigator(),
[this]{
[]{
wxGetApp().toggle_show_3d_navigator();
ImGui::CloseCurrentPopup(); // Close popup to show changes on UI
}
@@ -9518,7 +9518,7 @@ void GLCanvas3D::_render_canvas_toolbar()
create_menu_item( _utf8(L("Zoom button")),
true, // work on all
wxGetApp().show_canvas_zoom_button(),
[this]{
[]{
wxGetApp().toggle_canvas_zoom_button();
ImGui::CloseCurrentPopup(); // Close popup to show changes on UI
}
@@ -9529,13 +9529,13 @@ void GLCanvas3D::_render_canvas_toolbar()
create_menu_item( _utf8(L("Overhangs")),
m_canvas_type == ECanvasType::CanvasView3D, // work only on prepare
p->is_view3D_overhang_shown(),
[this, p]{p->show_view3D_overhang(!p->is_view3D_overhang_shown());}
[p]{p->show_view3D_overhang(!p->is_view3D_overhang_shown());}
);
create_menu_item( _utf8(L("Outline")),
m_canvas_type != ECanvasType::CanvasPreview, // not work on preview
wxGetApp().show_outline(),
[this]{wxGetApp().toggle_show_outline();}
[]{wxGetApp().toggle_show_outline();}
);
create_menu_item( _utf8(L("Wireframe")),
@@ -9547,7 +9547,7 @@ void GLCanvas3D::_render_canvas_toolbar()
create_menu_item( _utf8(L("Realistic View")),
m_canvas_type != ECanvasType::CanvasPreview, // not work on preview
cfg->get_bool(SETTING_OPENGL_REALISTIC_MODE),
[this, &cfg]{
[&cfg]{
cfg->set_bool(SETTING_OPENGL_REALISTIC_MODE, !cfg->get_bool(SETTING_OPENGL_REALISTIC_MODE));
cfg->save();
}
@@ -9558,7 +9558,7 @@ void GLCanvas3D::_render_canvas_toolbar()
create_menu_item( _utf8(L("Perspective")),
true, // work on all
cfg->get_bool("use_perspective_camera"),
[this, &cfg]{
[&cfg]{
cfg->set_bool("use_perspective_camera", !(cfg->get_bool("use_perspective_camera")));
wxGetApp().update_ui_from_settings();
}
@@ -9575,7 +9575,7 @@ void GLCanvas3D::_render_canvas_toolbar()
create_menu_item( _utf8(L("Gridlines")),
m_canvas_type != ECanvasType::CanvasAssembleView, // not work on assembly
wxGetApp().show_plate_gridlines(),
[this]{wxGetApp().toggle_show_plate_gridlines();}
[]{wxGetApp().toggle_show_plate_gridlines();}
);
ImGui::Separator();
@@ -9583,7 +9583,7 @@ void GLCanvas3D::_render_canvas_toolbar()
create_menu_item( _utf8(L("Labels")),
m_canvas_type == ECanvasType::CanvasView3D, // work only on prepare
p->are_view3D_labels_shown(),
[this, p]{p->show_view3D_labels(!p->are_view3D_labels_shown());}
[p]{p->show_view3D_labels(!p->are_view3D_labels_shown());}
);
ImGui::PopItemFlag();