From 311cd0307ebb6a93434533e3c664a00f0a395e53 Mon Sep 17 00:00:00 2001 From: Petros S Date: Sat, 9 Oct 2021 19:15:38 +0300 Subject: [PATCH] Small enhancements in the SdbWidget class. (#2796) * Small enhancements in SdbWidget class. Destructors of child classes should be marked with the `override` keyword. Also since Qt's widgets aren't movable or copyable, we can explicitly let the compiler know with the `Q_DISABLE_COPY_MOVE` macro. * Define Q_DISABLE_COPY_MOVE macro for versions < 5.13.0 in SdbWidget --- src/widgets/SdbWidget.cpp | 2 +- src/widgets/SdbWidget.h | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/widgets/SdbWidget.cpp b/src/widgets/SdbWidget.cpp index 98726e0e..37f3e419 100644 --- a/src/widgets/SdbWidget.cpp +++ b/src/widgets/SdbWidget.cpp @@ -80,7 +80,7 @@ void SdbWidget::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int colum } } -SdbWidget::~SdbWidget() {} +SdbWidget::~SdbWidget() = default; void SdbWidget::on_lockButton_clicked() { diff --git a/src/widgets/SdbWidget.h b/src/widgets/SdbWidget.h index a420d326..42b1457f 100644 --- a/src/widgets/SdbWidget.h +++ b/src/widgets/SdbWidget.h @@ -16,9 +16,25 @@ class SdbWidget : public CutterDockWidget { Q_OBJECT +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) +# define Q_DISABLE_COPY(SdbWidget) \ + SdbWidget(const SdbWidget &s) = delete; \ + SdbWidget &operator=(const SdbWidget &s) = delete; + +# define Q_DISABLE_MOVE(SdbWidget) \ + SdbWidget(SdbWidget &&s) = delete; \ + SdbWidget &operator=(SdbWidget &&s) = delete; + +# define Q_DISABLE_COPY_MOVE(SdbWidget) \ + Q_DISABLE_COPY(SdbWidget) \ + Q_DISABLE_MOVE(SdbWidget) +#endif + + Q_DISABLE_COPY_MOVE(SdbWidget) + public: explicit SdbWidget(MainWindow *main); - ~SdbWidget(); + ~SdbWidget() override; private slots: void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);