Remove null checks before delete (#17375)

Deleting a null pointer already does nothing. Enable clang-tidy's readability-delete-null-pointer so new null checks around delete are caught on changed lines, drop the one in DragCanvas's destructor, and remove ParamsPanel::delete_subwindows(), whose only caller is inside #if 0.

The --fix help and summary message in the clang-tidy scripts are reworded to "apply clang-tidy's fixes", since this check has its own fix.

Closes #7847
This commit is contained in:
TheLegendTubaGuy authored and GitHub committed 2026-11-09 07:55:35 -06:00
1 parent 80bfb59837
commit b4bd9c8492
7 files changed
+9 -92

No files matched your search

+3 -2
View File
@@ -1,5 +1,5 @@
# clang-tidy configuration, enforced by the clang-tidy CI job on the lines a pull
# request changes (scripts/clang_tidy_diff.py). Two things are reported.
# request changes (scripts/clang_tidy_diff.py). Three things are reported.
# Missing includes: a file should include the header for every symbol it uses, not
# rely on the precompiled header or another header's includes. Run with --fix to
# add them.
@@ -7,9 +7,10 @@
# they reach every file that includes the header, and a using-declaration also
# makes the header look like the one to include for that name. Qualify the name
# in the header, and put the using in the source files that want it.
# A null check around delete: deleting a null pointer already does nothing.
# Every check listed here gates pull requests, so enable a new one only once the
# code it flags on touched lines is reasonable to fix in passing.
Checks: '-*,misc-include-cleaner,google-global-names-in-headers'
Checks: '-*,misc-include-cleaner,google-global-names-in-headers,readability-delete-null-pointer'
WarningsAsErrors: '*'
CheckOptions:
# Missing includes only. Builds without the precompiled header break on these.
+2 -2
View File
@@ -8,7 +8,7 @@ include) fails wherever the error is. Headers are compiled on their own, and
fail only on errors in their changed lines. Deleting an #include also fails
on every use, changed or not, that now lacks the header it provided.
With -- --fix, clang-tidy adds the missing includes, on those lines only, and
With -- --fix, clang-tidy applies its fixes, on those lines only, and
each file it changed is checked again so that only what remains is reported.
The checks come from .clang-tidy at the repository root. The compile database
@@ -307,7 +307,7 @@ def main():
print(f"... and {len(diagnostics) - MAX_REPORTED} more")
if fixed:
print(f"\nAdded includes to {len(fixed)} file(s):")
print(f"\nApplied clang-tidy's fixes to {len(fixed)} file(s):")
for path in fixed:
print(f" {path}")
if failed and fixed:
+1 -1
View File
@@ -30,7 +30,7 @@ param(
[string]$Arch = "",
# Parallel clang-tidy runs (default: all cores).
[int]$Jobs = 0,
# Apply clang-tidy's fixes (adds the missing includes).
# Apply clang-tidy's fixes.
[switch]$Fix,
# Install missing tools without asking.
[switch]$Yes
+2 -2
View File
@@ -3,7 +3,7 @@
# on your branch, so its findings match what CI reports. Linux and macOS.
#
# scripts/run_clang_tidy.sh check your changes against OrcaSlicer's main
# scripts/run_clang_tidy.sh --fix also add the missing includes it names
# scripts/run_clang_tidy.sh --fix also apply clang-tidy's fixes
#
# It configures a separate build directory (build-tidy) without the precompiled
# header, uses the clang-tidy on your system or installs the pinned one into a
@@ -23,7 +23,7 @@ Usage: scripts/run_clang_tidy.sh [options]
-d, --deps-dir DIR dependency build directory (default: deps/build on Linux,
deps/build/<arch> on macOS)
-j, --jobs N parallel clang-tidy runs (default: all cores)
--fix apply clang-tidy's fixes (adds the missing includes)
--fix apply clang-tidy's fixes
-y, --yes install missing tools without asking; another clang-tidy
version found on the system is then not offered
-h, --help show this help
+1 -2
View File
@@ -52,8 +52,7 @@ DragCanvas::~DragCanvas()
}
m_dragshape_list.clear();
if (m_drag_image)
delete m_drag_image;
delete m_drag_image;
}
void DragCanvas::set_shape_list(const std::vector<std::string>& colors, const std::vector<int>& order)
-82
View File
@@ -809,93 +809,11 @@ void ParamsPanel::free_sizers()
m_button_sizer = nullptr;
}
void ParamsPanel::delete_subwindows()
{
if (m_title_label)
{
delete m_title_label;
m_title_label = nullptr;
}
if (m_mode_region)
{
delete m_mode_region;
m_mode_region = nullptr;
}
if (m_mode_view)
{
m_mode_view = nullptr;
}
if (m_mode_icon) // ORCA m_title_view replacement
{
delete m_mode_icon;
m_mode_icon = nullptr;
}
if (m_search_btn)
{
delete m_search_btn;
m_search_btn = nullptr;
}
if (m_staticline_print)
{
delete m_staticline_print;
m_staticline_print = nullptr;
}
if (m_staticline_print_part)
{
delete m_staticline_print_part;
m_staticline_print_part = nullptr;
}
if (m_staticline_print_object)
{
delete m_staticline_print_object;
m_staticline_print_object = nullptr;
}
if (m_staticline_filament)
{
delete m_staticline_filament;
m_staticline_filament = nullptr;
}
if (m_staticline_printer)
{
delete m_staticline_printer;
m_staticline_printer = nullptr;
}
if (m_export_to_file)
{
delete m_export_to_file;
m_export_to_file = nullptr;
}
if (m_import_from_file)
{
delete m_import_from_file;
m_import_from_file = nullptr;
}
if (m_page_view)
{
delete m_page_view;
m_page_view = nullptr;
}
}
ParamsPanel::~ParamsPanel()
{
#if 0
free_sizers();
delete m_top_sizer;
delete_subwindows();
#endif
// BBS: fix double destruct of OG_CustomCtrl
Tab* cur_tab = dynamic_cast<Tab*> (m_current_tab);
-1
View File
@@ -74,7 +74,6 @@ class ParamsPanel : public wxPanel
private:
void free_sizers();
void delete_subwindows();
void refresh_tabs();
protected: