build: mark missing overrides and drop unused lambda captures (1,156 clang warnings) (#15334)

* chore: mark every declaration that overrides a base virtual

clang-cl reports 42 member functions across 28 files that override a
base virtual without being marked `override`, inside classes that
already mark their other overrides. That is every occurrence of
-Winconsistent-missing-override in the tree, so the category drops to
zero and -Werror=inconsistent-missing-override becomes available as a
guard against it coming back.

Behaviour is unchanged. Each keyword goes only where clang had already
resolved the declaration to a base virtual, so it records what the
compiler already worked out and cannot affect overload resolution or
dispatch. If any of these signatures had not really overridden a base
method, the build would have failed rather than warned.

Where a declaration already carried `virtual` it is left alone and the
keyword appended, matching the surrounding declarations. Plain
`override` is used rather than the wxWidgets `wxOVERRIDE` macro, which
wx/defs.h defines as `override` beneath a comment marking it obsolete,
and which the rest of src/slic3r already avoids by 1742 occurrences to
113.

A full clang-cl build takes -Winconsistent-missing-override from 1,146
warning lines to 0. Those 42 declarations produce that many lines
because a header is re-diagnosed in every translation unit that
includes it. CalibrationWizardStartPage.hpp alone accounts for 336 of
them from 4 declarations.

* chore: drop unused lambda captures in GUI/Widgets

clang-cl reports 10 lambda captures in src/slic3r/GUI/Widgets that are
never read. Removing them changes nothing at runtime.

Every capture removed is `this` or a raw pointer. clang does not report
a capture whose type has a non-trivial destructor, since such a capture
can be held purely for its effect on an object's lifetime, so nothing
that owns or extends a lifetime is touched. The std::weak_ptr captured
beside the removed `this` in MultiNozzleSync.cpp stays.

This clears the category in GUI/Widgets only. A full clang-cl build
takes -Wunused-lambda-capture from 312 warning lines to 302, leaving
235 sites in other directories for a follow-up.
This commit is contained in:
Kris Austin
2026-08-25 06:18:48 -05:00
committed by GitHub
parent 524fd5e9c0
commit 56f9edc572
32 changed files with 52 additions and 52 deletions

View File

@@ -930,8 +930,8 @@ public:
// If preview_data is not null, the preview_data is filled in for the G-code visualization (not used by the command line Slic3r).
std::string export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb = nullptr);
//return 0 means successful
int export_cached_data(const std::string& dir_path, bool with_space=false);
int load_cached_data(const std::string& directory);
int export_cached_data(const std::string& dir_path, bool with_space=false) override;
int load_cached_data(const std::string& directory) override;
// methods for handling state
bool is_step_done(PrintStep step) const { return Inherited::is_step_done(step); }

View File

@@ -193,7 +193,7 @@ public:
void show_panels(CalibrationMethod method, const PrinterSeries printer_ser);
void on_device_connected(MachineObject* obj);
void on_device_connected(MachineObject* obj) override;
void update(MachineObject* obj) override;

View File

@@ -48,8 +48,8 @@ public:
void create_page(wxWindow* parent);
void on_reset_page();
void on_device_connected(MachineObject* obj);
void on_reset_page() override;
void on_device_connected(MachineObject* obj) override;
void msw_rescale() override;
};
@@ -63,8 +63,8 @@ public:
long style = wxTAB_TRAVERSAL);
void create_page(wxWindow* parent);
void on_reset_page();
void on_device_connected(MachineObject* obj);
void on_reset_page() override;
void on_device_connected(MachineObject* obj) override;
void msw_rescale() override;
};

View File

@@ -385,7 +385,7 @@ public:
wxWindow* window{ nullptr };
void BUILD() override;
/// Propagate value from field to the OptionGroupe and Config after kill_focus/ENTER
void propagate_value() ;
void propagate_value() override;
void set_value(const std::string& value, bool change_event = false) {
m_disable_change_event = !change_event;
@@ -440,7 +440,7 @@ public:
wxWindow* window{ nullptr };
void BUILD() override;
// Propagate value from field to the OptionGroupe and Config after kill_focus/ENTER
void propagate_value();
void propagate_value() override;
/* Under OSX: wxBitmapComboBox->GetWindowStyle() returns some weard value,
* so let use a flag, which has TRUE value for a control without wxCB_READONLY style

View File

@@ -85,7 +85,7 @@ public:
void update_model_object();
//ClippingPlane get_sla_clipping_plane() const;
bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); }
bool is_selection_rectangle_dragging() const override { return m_selection_rectangle.is_dragging(); }
bool wants_enter_leave_snapshots() const override { return true; }
std::string get_gizmo_entering_text() const override { return _u8L("Entering Brim Ears"); }

View File

@@ -75,7 +75,7 @@ protected:
virtual void on_render() override;
virtual void on_set_state() override;
virtual CommonGizmosDataID on_get_requirements() const override;
virtual void on_render_input_window(float x, float y, float bottom_limit);
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
void on_load(cereal::BinaryInputArchive &ar) override;
void on_save(cereal::BinaryOutputArchive &ar) const override;

View File

@@ -67,7 +67,7 @@ protected:
void on_register_raycasters_for_picking() override;
void on_unregister_raycasters_for_picking() override;
//BBS: GUI refactor: add object manipulation
virtual void on_render_input_window(float x, float y, float bottom_limit);
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
private:
double calc_projection(const UpdateData& data) const;

View File

@@ -89,7 +89,7 @@ protected:
virtual void on_register_raycasters_for_picking() override;
virtual void on_unregister_raycasters_for_picking() override;
//BBS: GUI refactor: add object manipulation
virtual void on_render_input_window(float x, float y, float bottom_limit);
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
private:
void render_grabbers_connection(unsigned int id_1, unsigned int id_2, const ColorRGBA& color);

View File

@@ -79,7 +79,7 @@ public:
Bind(wxEVT_LEFT_DOWN, &WikiLabel::OnLeftDown, this);
}
void SetLabel(const wxString& label)
void SetLabel(const wxString& label) override
{
m_label = label;
m_last_wrap_width = -1; // force re-wrap

View File

@@ -163,7 +163,7 @@ public:
BedType bedType() const { return m_BedType; }
virtual void init() override;
virtual std::map<std::string, std::string> extendedInfo() const
virtual std::map<std::string, std::string> extendedInfo() const override
{
return {{"bedType", std::to_string(static_cast<int>(m_BedType))},
{"timeLapse", std::to_string(m_timeLapse)},
@@ -200,7 +200,7 @@ public:
PrintHost* printhost);
virtual void init() override;
virtual std::map<std::string, std::string> extendedInfo() const;
virtual std::map<std::string, std::string> extendedInfo() const override;
private:
static constexpr const char* CONFIG_KEY_ENABLESELFTEST = "crealityprint_enable_self_test";

View File

@@ -522,7 +522,7 @@ public:
bool is_timeout();
int update_print_required_data(Slic3r::DynamicPrintConfig config, Slic3r::Model model, Slic3r::PlateDataPtrs plate_data_list, std::string file_name, std::string file_path);
void set_print_type(PrintFromType type) {m_print_type = type;};
bool Show(bool show);
bool Show(bool show) override;
void show_init();
bool do_ams_mapping(MachineObject *obj_,bool use_ams);
bool get_ams_mapping_result(std::string& mapping_array_str, std::string& mapping_array_str2, std::string& ams_mapping_info) const;

View File

@@ -180,7 +180,7 @@ public:
SendToPrinterDialog(Plater *plater = nullptr);
~SendToPrinterDialog();
bool Show(bool show);
bool Show(bool show) override;
bool is_timeout();
void on_rename_click(wxCommandEvent& event);
void on_rename_enter();

View File

@@ -371,7 +371,7 @@ public:
};
FinishSyncAmsDialog(InputInfo &input_info);
~FinishSyncAmsDialog() override;
void deal_ok();
void deal_ok() override;
void update_info(InputInfo& info);
bool Layout() override;

View File

@@ -515,13 +515,13 @@ public:
bool has_key(std::string const &key);
protected:
virtual void activate_selected_page(std::function<void()> throw_if_canceled);
virtual void activate_selected_page(std::function<void()> throw_if_canceled) override;
virtual void on_value_change(const std::string& opt_key, const boost::any& value) override;
virtual void notify_changed(ObjectBase * object) = 0;
virtual void reload_config();
virtual void reload_config() override;
virtual void update_custom_dirty(std::vector<std::string> &dirty_options, std::vector<std::string> &nonsys_options) override;

View File

@@ -40,7 +40,7 @@ public:
void SetBitmap(ScalableBitmap &bitmap);
bool Enable(bool enable = true);
bool Enable(bool enable = true) override;
void Rescale();

View File

@@ -166,7 +166,7 @@ public:
return true;
}
bool RemovePage(size_t n)
bool RemovePage(size_t n) override
{
if (!wxBookCtrlBase::RemovePage(n))
return false;

View File

@@ -343,7 +343,7 @@ public:
UnsavedChangesDialog(const wxString &caption, const wxString &header, DynamicConfig *config, int from, int to, bool left_to_right, NozzleVolumeType nozzle);
~UnsavedChangesDialog() override = default;
int ShowModal();
int ShowModal() override;
void build(Preset::Type type, PresetCollection *dependent_presets, const std::string &new_selected_preset, const wxString &header = "");
void update(Preset::Type type, PresetCollection* dependent_presets, const std::string& new_selected_preset, const wxString& header);

View File

@@ -630,7 +630,7 @@ NozzleListTable::NozzleListTable(wxWindow* parent) : wxPanel(parent,wxID_ANY,wxD
SetSizer(sizer);
Layout();
m_web_view->Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, [this,sizer](wxWebViewEvent& evt) {
m_web_view->Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, [this](wxWebViewEvent& evt) {
std::string message = evt.GetString().ToStdString();
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << "Received message: " << message;
try {
@@ -1168,8 +1168,8 @@ void MultiNozzleSyncDialog::UpdateButton(std::weak_ptr<DevNozzleRack> rack, bool
m_cancel_btn->SetLabel(_L("Ignore"));
m_confirm_btn->SetLabel(_L("Refresh"));
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, ignore_opt](auto& e) {ignore_opt(); });
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, refresh_cmd](auto& e) {refresh_cmd(); });
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [rack, ignore_opt](auto& e) {ignore_opt(); });
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [rack, refresh_cmd](auto& e) {refresh_cmd(); });
}
else if (has_unknown) {
m_cancel_btn->Show();
@@ -1178,8 +1178,8 @@ void MultiNozzleSyncDialog::UpdateButton(std::weak_ptr<DevNozzleRack> rack, bool
m_cancel_btn->SetLabel(_L("Ignore"));
m_confirm_btn->SetLabel(_L("Refresh"));
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, ignore_opt](auto& e) {ignore_opt(); });
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, refresh_cmd](auto& e) {refresh_cmd(); });
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [rack, ignore_opt](auto& e) {ignore_opt(); });
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [rack, refresh_cmd](auto& e) {refresh_cmd(); });
}
else if (has_unreliable) {
m_cancel_btn->Show();
@@ -1188,8 +1188,8 @@ void MultiNozzleSyncDialog::UpdateButton(std::weak_ptr<DevNozzleRack> rack, bool
m_cancel_btn->SetLabel(_L("Refresh"));
m_confirm_btn->SetLabel(_L("Confirm"));
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, refresh_cmd](auto& e) {refresh_cmd(); });
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, trust_cmd](auto& e) {trust_cmd(); });
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [rack, refresh_cmd](auto& e) {refresh_cmd(); });
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [rack, trust_cmd](auto& e) {trust_cmd(); });
}
else {

View File

@@ -167,7 +167,7 @@ class MultiNozzleSyncDialog : public DPIDialog
{
public:
MultiNozzleSyncDialog(wxWindow* parent, std::weak_ptr<DevNozzleRack> rack);
virtual void on_dpi_changed(const wxRect& suggested_rect) {};
virtual void on_dpi_changed(const wxRect& suggested_rect) override {};
std::vector<NozzleOption> GetNozzleOptions(const std::vector<MultiNozzleUtils::NozzleGroupInfo>& group_infos);
std::optional<NozzleOption> GetSelectedOption() {

View File

@@ -56,7 +56,7 @@ protected:
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
void doRender(wxDC &dc);
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;

View File

@@ -33,7 +33,7 @@ public:
void OnPaint(wxPaintEvent &evt);
virtual ~ProgressDialog();
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;
bool Create(const wxString &title, const wxString &message, int maximum = 100, wxWindow *parent = NULL, int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE);
virtual bool Update(int value, const wxString &newmsg = wxEmptyString, bool *skip = NULL);

View File

@@ -31,7 +31,7 @@ public:
void SetLayoutStyle(int style);
void SetLabel(const wxString& label);
void SetLabel(const wxString& label) override;
bool SetForegroundColour(wxColour const & colour) override;
@@ -47,7 +47,7 @@ public:
void SetBackgroundColor(StateColor const &color);
bool Enable(bool enable = true);
bool Enable(bool enable = true) override;
void Rescale();

View File

@@ -75,7 +75,7 @@ void SpinInput::Create(wxWindow *parent,
text_ctrl->Bind(wxEVT_KILL_FOCUS, &SpinInput::onTextLostFocus, this);
text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInput::onTextEnter, this);
text_ctrl->Bind(wxEVT_KEY_DOWN, &SpinInput::keyPressed, this);
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu
button_inc = createButton(true);
button_dec = createButton(false);
delta = 0;

View File

@@ -63,7 +63,7 @@ public:
bool IsVisible(unsigned int item) const;
private:
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;
#ifdef __WIN32__
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) override;

View File

@@ -134,7 +134,7 @@ void TempInput::Create(wxWindow *parent, wxString text, wxString label, wxString
}
}
});
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu
text_ctrl->Bind(wxEVT_LEFT_DOWN, [this](auto &e) {
if (m_read_only) {
return;

View File

@@ -107,7 +107,7 @@ public:
wxString GetTagTemp() { return text_ctrl->GetValue(); }
wxString GetCurrTemp() { return GetLabel(); }
int get_max_temp() { return max_temp; }
void SetLabel(const wxString &label);
void SetLabel(const wxString &label) override;
void SetTextColor(StateColor const &color);
@@ -128,7 +128,7 @@ public:
void ReSetOnChanging() { m_on_changing = false; }
protected:
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;
void DoSetToolTipText(wxString const &tip) override;

View File

@@ -85,7 +85,7 @@ void TextInput::Create(wxWindow * parent,
e.SetId(GetId());
ProcessEventLocally(e);
});
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu
if (!icon.IsEmpty()) {
this->icon = ScalableBitmap(this, icon.ToStdString(), 16);
}

View File

@@ -46,7 +46,7 @@ public:
// Only meant to be used by inspector, not public API
int GetCornerRadius() const { return static_cast<int>(radius); }
void SetLabel(const wxString& label);
void SetLabel(const wxString& label) override;
void SetStaticTips(const wxString& tips, const wxBitmap& bitmap);
@@ -73,7 +73,7 @@ protected:
virtual void OnEdit() {}
virtual void DoSetSize(
int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;
void DoSetToolTipText(wxString const &tip) override;

View File

@@ -104,7 +104,7 @@ DWORD DownloadAndInstallWV2RT() {
class WebViewEdge : public wxWebViewEdge
{
public:
bool SetUserAgent(const wxString &userAgent)
bool SetUserAgent(const wxString &userAgent) override
{
bool dark = userAgent.Contains("dark");
SetColorScheme(dark ? COREWEBVIEW2_PREFERRED_COLOR_SCHEME_DARK : COREWEBVIEW2_PREFERRED_COLOR_SCHEME_LIGHT);

View File

@@ -21,14 +21,14 @@ public:
~CrealityPrint() override = default;
const char* get_name() const override;
virtual bool can_test() const { return true; };
virtual bool can_test() const override { return true; };
std::string get_host() const override;
bool has_auto_discovery() const override { return true; }
wxString get_test_ok_msg() const override;
wxString get_test_failed_msg(wxString& msg) const override;
virtual bool test(wxString& curl_msg) const override;
PrintHostPostUploadActions get_post_upload_actions() const;
PrintHostPostUploadActions get_post_upload_actions() const override;
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const override;
bool supports_multi_color_print() const;
std::string query_boxes_info() const;

View File

@@ -32,10 +32,10 @@ public:
PrintHostPostUploadActions get_post_upload_actions() const override;
protected:
#ifdef WIN32
virtual bool upload_inner_with_resolved_ip(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn, const boost::asio::ip::address& resolved_addr) const;
virtual bool upload_inner_with_resolved_ip(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn, const boost::asio::ip::address& resolved_addr) const override;
#endif
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const;
virtual bool upload_inner_with_host(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const;
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const override;
virtual bool upload_inner_with_host(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const override;
#ifdef WIN32
virtual bool test_with_resolved_ip(wxString& curl_msg) const override;

View File

@@ -20,7 +20,7 @@ public:
~Obico() override = default;
const char* get_name() const override;
virtual bool can_test() const { return true; };
virtual bool can_test() const override { return true; };
bool has_auto_discovery() const override { return false; }
bool is_cloud() const override { return true; }
bool get_login_url(wxString& auth_url) const override;
@@ -30,7 +30,7 @@ public:
wxString get_test_failed_msg(wxString& msg) const override;
virtual bool test(wxString& curl_msg) const override;
bool get_printers(wxArrayString& printers) const override;
PrintHostPostUploadActions get_post_upload_actions() const;
PrintHostPostUploadActions get_post_upload_actions() const override;
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const override;
protected: