From 65656f6d22fc7beefa652fbee179a06f02fa22a8 Mon Sep 17 00:00:00 2001 From: donovaly Date: Fri, 5 Feb 2021 01:38:34 +0100 Subject: [PATCH] [Sketcher] make more pointers to the UI std::unique_ptr addendum to PR #4362 (Same as PR #4293, just for Sketcher as noted in https://github.com/FreeCAD/FreeCAD/pull/4271#discussion_r554673632 the pointer to the UI should be a unique pointer. This PR does this for all Sketcher dialogs that don't already use a unique_ptr.) --- src/Mod/Sketcher/Gui/SketchMirrorDialog.cpp | 1 - src/Mod/Sketcher/Gui/SketchMirrorDialog.h | 2 +- src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp | 1 - src/Mod/Sketcher/Gui/SketchOrientationDialog.h | 2 +- src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.cpp | 1 - src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.h | 2 +- src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.cpp | 1 - src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.h | 2 +- src/Mod/Sketcher/Gui/SketcherSettings.cpp | 3 --- src/Mod/Sketcher/Gui/SketcherSettings.h | 7 ++++--- 10 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Mod/Sketcher/Gui/SketchMirrorDialog.cpp b/src/Mod/Sketcher/Gui/SketchMirrorDialog.cpp index 149f9abc48..c26801db82 100644 --- a/src/Mod/Sketcher/Gui/SketchMirrorDialog.cpp +++ b/src/Mod/Sketcher/Gui/SketchMirrorDialog.cpp @@ -49,7 +49,6 @@ SketchMirrorDialog::SketchMirrorDialog(void) SketchMirrorDialog::~SketchMirrorDialog() { - delete ui; } void SketchMirrorDialog::accept() diff --git a/src/Mod/Sketcher/Gui/SketchMirrorDialog.h b/src/Mod/Sketcher/Gui/SketchMirrorDialog.h index a59a3ecaba..debea06eec 100644 --- a/src/Mod/Sketcher/Gui/SketchMirrorDialog.h +++ b/src/Mod/Sketcher/Gui/SketchMirrorDialog.h @@ -43,7 +43,7 @@ public: void accept(); private: - Ui_SketchMirrorDialog* ui; + std::unique_ptr ui; }; } diff --git a/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp b/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp index 3b4f86e731..329ffe0276 100644 --- a/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp +++ b/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp @@ -52,7 +52,6 @@ SketchOrientationDialog::SketchOrientationDialog(void) SketchOrientationDialog::~SketchOrientationDialog() { - delete ui; } void SketchOrientationDialog::accept() diff --git a/src/Mod/Sketcher/Gui/SketchOrientationDialog.h b/src/Mod/Sketcher/Gui/SketchOrientationDialog.h index a2782c0e4e..f8629cf2f0 100644 --- a/src/Mod/Sketcher/Gui/SketchOrientationDialog.h +++ b/src/Mod/Sketcher/Gui/SketchOrientationDialog.h @@ -46,7 +46,7 @@ protected Q_SLOTS: void onPreview(); private: - Ui_SketchOrientationDialog* ui; + std::unique_ptr ui; }; } diff --git a/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.cpp b/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.cpp index cc37c5f59c..fdd23e42df 100644 --- a/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.cpp +++ b/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.cpp @@ -53,7 +53,6 @@ SketchRectangularArrayDialog::SketchRectangularArrayDialog(void) SketchRectangularArrayDialog::~SketchRectangularArrayDialog() { - delete ui; } void SketchRectangularArrayDialog::accept() diff --git a/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.h b/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.h index 620c7e7796..602fb9fdc6 100644 --- a/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.h +++ b/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.h @@ -48,7 +48,7 @@ public: protected: void updateValues(void); private: - Ui_SketchRectangularArrayDialog* ui; + std::unique_ptr ui; }; } diff --git a/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.cpp b/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.cpp index bf7dc3ef88..91bbe2bd5a 100644 --- a/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.cpp +++ b/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.cpp @@ -49,7 +49,6 @@ SketcherRegularPolygonDialog::SketcherRegularPolygonDialog(void) SketcherRegularPolygonDialog::~SketcherRegularPolygonDialog() { - delete ui; } void SketcherRegularPolygonDialog::accept() diff --git a/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.h b/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.h index f450693620..1a21de3945 100644 --- a/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.h +++ b/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.h @@ -44,7 +44,7 @@ public: protected: void updateValues(void); private: - Ui_SketcherRegularPolygonDialog* ui; + std::unique_ptr ui; }; } diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.cpp b/src/Mod/Sketcher/Gui/SketcherSettings.cpp index e63f8e2b3b..02e41de8fe 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.cpp +++ b/src/Mod/Sketcher/Gui/SketcherSettings.cpp @@ -62,7 +62,6 @@ SketcherSettings::SketcherSettings(QWidget* parent) SketcherSettings::~SketcherSettings() { // no need to delete child widgets, Qt does it all for us - delete ui; } void SketcherSettings::saveSettings() @@ -141,7 +140,6 @@ SketcherSettingsDisplay::SketcherSettingsDisplay(QWidget* parent) SketcherSettingsDisplay::~SketcherSettingsDisplay() { // no need to delete child widgets, Qt does it all for us - delete ui; } void SketcherSettingsDisplay::saveSettings() @@ -241,7 +239,6 @@ SketcherSettingsColors::SketcherSettingsColors(QWidget* parent) SketcherSettingsColors::~SketcherSettingsColors() { // no need to delete child widgets, Qt does it all for us - delete ui; } void SketcherSettingsColors::saveSettings() diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.h b/src/Mod/Sketcher/Gui/SketcherSettings.h index 4d94156920..003c0fe0b9 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.h +++ b/src/Mod/Sketcher/Gui/SketcherSettings.h @@ -25,6 +25,7 @@ #define SKETCHERGUI_SKETCHERSETTINGS_H #include +#include namespace SketcherGui { class Ui_SketcherSettings; @@ -50,7 +51,7 @@ protected: void changeEvent(QEvent *e); private: - Ui_SketcherSettings* ui; + std::unique_ptr ui; SketcherGeneralWidget* form; }; @@ -76,7 +77,7 @@ private Q_SLOTS: void onBtnTVApplyClicked(bool); private: - Ui_SketcherSettingsDisplay* ui; + std::unique_ptr ui; }; /** @@ -98,7 +99,7 @@ protected: void changeEvent(QEvent *e); private: - Ui_SketcherSettingsColors* ui; + std::unique_ptr ui; }; } // namespace SketcherGui