From c8b4611d8d1c47b8db278659802a0aabd8f1a75c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 18 May 2022 13:43:04 +0800 Subject: [PATCH] Disable copy, move constructors when inheriting from QObject --- src/base/net/dnsupdater.h | 1 + src/base/net/smtp.h | 1 + src/base/preferences.h | 11 ++++++----- src/base/rss/rss_parser.h | 1 + src/base/settingsstorage.h | 2 ++ src/gui/autoexpandabledialog.h | 1 + src/gui/categoryfiltermodel.h | 1 + src/gui/cookiesdialog.h | 1 + src/gui/cookiesmodel.h | 1 + src/gui/deletionconfirmationdialog.h | 1 + src/gui/executionlogwidget.h | 1 + src/gui/fspathedit.h | 10 +++++++--- src/gui/fspathedit_p.h | 2 ++ src/gui/lineedit.h | 1 + src/gui/mainwindow.h | 1 + src/gui/powermanagement/powermanagement.h | 1 + src/gui/powermanagement/powermanagement_x11.h | 1 + src/gui/properties/peerlistwidget.h | 1 + src/gui/properties/peersadditiondialog.h | 1 + src/gui/properties/pieceavailabilitybar.h | 3 ++- src/gui/properties/piecesbar.h | 3 ++- src/gui/properties/speedplotview.h | 1 + src/gui/properties/speedwidget.h | 2 ++ src/gui/properties/trackersadditiondialog.h | 1 + src/gui/rss/articlelistwidget.h | 1 + src/gui/rss/feedlistwidget.h | 1 + src/gui/rss/htmlbrowser.h | 1 + src/gui/rss/rsswidget.h | 1 + src/gui/shutdownconfirmdialog.h | 1 + src/gui/tagfiltermodel.h | 1 + src/gui/tagfilterwidget.h | 1 + src/gui/torrentcontentfiltermodel.h | 1 + 32 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/base/net/dnsupdater.h b/src/base/net/dnsupdater.h index 3236833f1..5e03f8a20 100644 --- a/src/base/net/dnsupdater.h +++ b/src/base/net/dnsupdater.h @@ -43,6 +43,7 @@ namespace Net class DNSUpdater : public QObject { Q_OBJECT + Q_DISABLE_COPY_MOVE(DNSUpdater) public: explicit DNSUpdater(QObject *parent = nullptr); diff --git a/src/base/net/smtp.h b/src/base/net/smtp.h index 6b74198cd..42ec689e1 100644 --- a/src/base/net/smtp.h +++ b/src/base/net/smtp.h @@ -50,6 +50,7 @@ namespace Net class Smtp : public QObject { Q_OBJECT + Q_DISABLE_COPY_MOVE(Smtp) public: Smtp(QObject *parent = nullptr); diff --git a/src/base/preferences.h b/src/base/preferences.h index 9bfa3add4..068d1168e 100644 --- a/src/base/preferences.h +++ b/src/base/preferences.h @@ -94,11 +94,6 @@ class Preferences : public QObject Preferences(); - static Preferences *m_instance; - -signals: - void changed(); - public: static void initInstance(); static void freeInstance(); @@ -414,4 +409,10 @@ public slots: void setTrackerFilterState(bool checked); void apply(); + +signals: + void changed(); + +private: + static Preferences *m_instance; }; diff --git a/src/base/rss/rss_parser.h b/src/base/rss/rss_parser.h index 3d0ed4e72..675e5c9b3 100644 --- a/src/base/rss/rss_parser.h +++ b/src/base/rss/rss_parser.h @@ -52,6 +52,7 @@ namespace RSS class Parser : public QObject { Q_OBJECT + Q_DISABLE_COPY_MOVE(Parser) public: explicit Parser(QString lastBuildDate); diff --git a/src/base/settingsstorage.h b/src/base/settingsstorage.h index c22081589..6d761d73a 100644 --- a/src/base/settingsstorage.h +++ b/src/base/settingsstorage.h @@ -53,6 +53,8 @@ struct IsQFlags> : std::true_type {}; class SettingsStorage final : public QObject { Q_OBJECT + Q_DISABLE_COPY_MOVE(SettingsStorage) + SettingsStorage(); ~SettingsStorage(); diff --git a/src/gui/autoexpandabledialog.h b/src/gui/autoexpandabledialog.h index f692813c8..db5d0ea5d 100644 --- a/src/gui/autoexpandabledialog.h +++ b/src/gui/autoexpandabledialog.h @@ -41,6 +41,7 @@ namespace Ui class AutoExpandableDialog final : public QDialog { Q_OBJECT + Q_DISABLE_COPY_MOVE(AutoExpandableDialog) public: explicit AutoExpandableDialog(QWidget *parent); diff --git a/src/gui/categoryfiltermodel.h b/src/gui/categoryfiltermodel.h index 63ec637c2..51f5859df 100644 --- a/src/gui/categoryfiltermodel.h +++ b/src/gui/categoryfiltermodel.h @@ -42,6 +42,7 @@ namespace BitTorrent class CategoryFilterModel final : public QAbstractItemModel { Q_OBJECT + Q_DISABLE_COPY_MOVE(CategoryFilterModel) public: explicit CategoryFilterModel(QObject *parent = nullptr); diff --git a/src/gui/cookiesdialog.h b/src/gui/cookiesdialog.h index 9bb181880..b70bbfc54 100644 --- a/src/gui/cookiesdialog.h +++ b/src/gui/cookiesdialog.h @@ -42,6 +42,7 @@ namespace Ui class CookiesDialog final : public QDialog { Q_OBJECT + Q_DISABLE_COPY_MOVE(CookiesDialog) public: explicit CookiesDialog(QWidget *parent = nullptr); diff --git a/src/gui/cookiesmodel.h b/src/gui/cookiesmodel.h index 4beb8d9cb..db0eeaac5 100644 --- a/src/gui/cookiesmodel.h +++ b/src/gui/cookiesmodel.h @@ -35,6 +35,7 @@ class CookiesModel final : public QAbstractItemModel { Q_OBJECT + Q_DISABLE_COPY_MOVE(CookiesModel) public: enum Column diff --git a/src/gui/deletionconfirmationdialog.h b/src/gui/deletionconfirmationdialog.h index 8c08450fe..e65fe9a45 100644 --- a/src/gui/deletionconfirmationdialog.h +++ b/src/gui/deletionconfirmationdialog.h @@ -40,6 +40,7 @@ namespace Ui class DeletionConfirmationDialog : public QDialog { Q_OBJECT + Q_DISABLE_COPY_MOVE(DeletionConfirmationDialog) public: DeletionConfirmationDialog(QWidget *parent, int size, const QString &name, bool defaultDeleteFiles); diff --git a/src/gui/executionlogwidget.h b/src/gui/executionlogwidget.h index e22d136f6..99e52ec61 100644 --- a/src/gui/executionlogwidget.h +++ b/src/gui/executionlogwidget.h @@ -44,6 +44,7 @@ class LogListView; class ExecutionLogWidget : public QWidget { Q_OBJECT + Q_DISABLE_COPY_MOVE(ExecutionLogWidget) public: ExecutionLogWidget(Log::MsgTypes types, QWidget *parent); diff --git a/src/gui/fspathedit.h b/src/gui/fspathedit.h index 2409e893a..2f697544c 100644 --- a/src/gui/fspathedit.h +++ b/src/gui/fspathedit.h @@ -46,11 +46,15 @@ namespace Private class FileSystemPathEdit : public QWidget { Q_OBJECT + Q_DISABLE_COPY_MOVE(FileSystemPathEdit) + Q_PROPERTY(Mode mode READ mode WRITE setMode) Q_PROPERTY(Path selectedPath READ selectedPath WRITE setSelectedPath NOTIFY selectedPathChanged) Q_PROPERTY(QString fileNameFilter READ fileNameFilter WRITE setFileNameFilter) Q_PROPERTY(QString dialogCaption READ dialogCaption WRITE setDialogCaption) + class FileSystemPathEditPrivate; + public: ~FileSystemPathEdit() override; @@ -100,13 +104,13 @@ protected slots: void onPathEdited(); private: + Q_DECLARE_PRIVATE(FileSystemPathEdit) + virtual QString editWidgetText() const = 0; virtual void setEditWidgetText(const QString &text) = 0; QWidget *editWidgetImpl() const; - Q_DISABLE_COPY_MOVE(FileSystemPathEdit) - class FileSystemPathEditPrivate; - Q_DECLARE_PRIVATE(FileSystemPathEdit) + FileSystemPathEditPrivate *d_ptr; }; diff --git a/src/gui/fspathedit_p.h b/src/gui/fspathedit_p.h index ee8fc9d41..28c858852 100644 --- a/src/gui/fspathedit_p.h +++ b/src/gui/fspathedit_p.h @@ -47,6 +47,7 @@ namespace Private class FileSystemPathValidator final : public QValidator { Q_OBJECT + Q_DISABLE_COPY_MOVE(FileSystemPathValidator) public: FileSystemPathValidator(QObject *parent = nullptr); @@ -147,6 +148,7 @@ namespace Private class FileComboEdit final : public QComboBox, public FileEditorWithCompletion { Q_OBJECT + Q_DISABLE_COPY_MOVE(FileComboEdit) public: FileComboEdit(QWidget *parent = nullptr); diff --git a/src/gui/lineedit.h b/src/gui/lineedit.h index 1df63ad6d..856fcc569 100644 --- a/src/gui/lineedit.h +++ b/src/gui/lineedit.h @@ -16,6 +16,7 @@ class QToolButton; class LineEdit final : public QLineEdit { Q_OBJECT + Q_DISABLE_COPY_MOVE(LineEdit) public: LineEdit(QWidget *parent); diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index a14894a65..de402ae2b 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -74,6 +74,7 @@ namespace Ui class MainWindow final : public QMainWindow { Q_OBJECT + Q_DISABLE_COPY_MOVE(MainWindow) public: explicit MainWindow(QWidget *parent = nullptr); diff --git a/src/gui/powermanagement/powermanagement.h b/src/gui/powermanagement/powermanagement.h index 141856837..d817e2a24 100644 --- a/src/gui/powermanagement/powermanagement.h +++ b/src/gui/powermanagement/powermanagement.h @@ -43,6 +43,7 @@ class PowerManagementInhibitor; class PowerManagement : public QObject { Q_OBJECT + Q_DISABLE_COPY_MOVE(PowerManagement) public: PowerManagement(QObject *parent = nullptr); diff --git a/src/gui/powermanagement/powermanagement_x11.h b/src/gui/powermanagement/powermanagement_x11.h index b83ea6f0b..34defe1b8 100644 --- a/src/gui/powermanagement/powermanagement_x11.h +++ b/src/gui/powermanagement/powermanagement_x11.h @@ -35,6 +35,7 @@ class QDBusPendingCallWatcher; class PowerManagementInhibitor : public QObject { Q_OBJECT + Q_DISABLE_COPY_MOVE(PowerManagementInhibitor) public: PowerManagementInhibitor(QObject *parent = nullptr); diff --git a/src/gui/properties/peerlistwidget.h b/src/gui/properties/peerlistwidget.h index 44d3b6126..a3e9e0d94 100644 --- a/src/gui/properties/peerlistwidget.h +++ b/src/gui/properties/peerlistwidget.h @@ -55,6 +55,7 @@ namespace Net class PeerListWidget final : public QTreeView { Q_OBJECT + Q_DISABLE_COPY_MOVE(PeerListWidget) public: enum PeerListColumns diff --git a/src/gui/properties/peersadditiondialog.h b/src/gui/properties/peersadditiondialog.h index fab3075bb..6033d31e8 100644 --- a/src/gui/properties/peersadditiondialog.h +++ b/src/gui/properties/peersadditiondialog.h @@ -41,6 +41,7 @@ namespace Ui class PeersAdditionDialog : public QDialog { Q_OBJECT + Q_DISABLE_COPY_MOVE(PeersAdditionDialog) public: PeersAdditionDialog(QWidget *parent); diff --git a/src/gui/properties/pieceavailabilitybar.h b/src/gui/properties/pieceavailabilitybar.h index 97a1c6d87..05472d489 100644 --- a/src/gui/properties/pieceavailabilitybar.h +++ b/src/gui/properties/pieceavailabilitybar.h @@ -32,10 +32,11 @@ class PieceAvailabilityBar final : public PiecesBar { - using base = PiecesBar; Q_OBJECT Q_DISABLE_COPY_MOVE(PieceAvailabilityBar) + using base = PiecesBar; + public: PieceAvailabilityBar(QWidget *parent); diff --git a/src/gui/properties/piecesbar.h b/src/gui/properties/piecesbar.h index f5518c200..1ee7299d4 100644 --- a/src/gui/properties/piecesbar.h +++ b/src/gui/properties/piecesbar.h @@ -42,10 +42,11 @@ namespace BitTorrent class PiecesBar : public QWidget { - using base = QWidget; Q_OBJECT Q_DISABLE_COPY_MOVE(PiecesBar) + using base = QWidget; + public: explicit PiecesBar(QWidget *parent = nullptr); diff --git a/src/gui/properties/speedplotview.h b/src/gui/properties/speedplotview.h index 464f904b4..1beedcc97 100644 --- a/src/gui/properties/speedplotview.h +++ b/src/gui/properties/speedplotview.h @@ -48,6 +48,7 @@ using namespace std::chrono_literals; class SpeedPlotView final : public QGraphicsView { Q_OBJECT + Q_DISABLE_COPY_MOVE(SpeedPlotView) public: enum GraphID diff --git a/src/gui/properties/speedwidget.h b/src/gui/properties/speedwidget.h index 976d757bb..97d17192b 100644 --- a/src/gui/properties/speedwidget.h +++ b/src/gui/properties/speedwidget.h @@ -42,6 +42,7 @@ class SpeedPlotView; class ComboBoxMenuButton final : public QComboBox { Q_OBJECT + Q_DISABLE_COPY_MOVE(ComboBoxMenuButton) public: ComboBoxMenuButton(QWidget *parent, QMenu *menu); @@ -55,6 +56,7 @@ private: class SpeedWidget : public QWidget { Q_OBJECT + Q_DISABLE_COPY_MOVE(SpeedWidget) public: explicit SpeedWidget(PropertiesWidget *parent); diff --git a/src/gui/properties/trackersadditiondialog.h b/src/gui/properties/trackersadditiondialog.h index f05338a10..b1ac9f773 100644 --- a/src/gui/properties/trackersadditiondialog.h +++ b/src/gui/properties/trackersadditiondialog.h @@ -51,6 +51,7 @@ namespace Ui class TrackersAdditionDialog : public QDialog { Q_OBJECT + Q_DISABLE_COPY_MOVE(TrackersAdditionDialog) public: TrackersAdditionDialog(QWidget *parent, BitTorrent::Torrent *const torrent); diff --git a/src/gui/rss/articlelistwidget.h b/src/gui/rss/articlelistwidget.h index 0e74e4088..16c0fe089 100644 --- a/src/gui/rss/articlelistwidget.h +++ b/src/gui/rss/articlelistwidget.h @@ -40,6 +40,7 @@ namespace RSS class ArticleListWidget : public QListWidget { Q_OBJECT + Q_DISABLE_COPY_MOVE(ArticleListWidget) public: explicit ArticleListWidget(QWidget *parent); diff --git a/src/gui/rss/feedlistwidget.h b/src/gui/rss/feedlistwidget.h index 8bb8ea08b..569011a8c 100644 --- a/src/gui/rss/feedlistwidget.h +++ b/src/gui/rss/feedlistwidget.h @@ -43,6 +43,7 @@ namespace RSS class FeedListWidget final : public QTreeWidget { Q_OBJECT + Q_DISABLE_COPY_MOVE(FeedListWidget) public: explicit FeedListWidget(QWidget *parent); diff --git a/src/gui/rss/htmlbrowser.h b/src/gui/rss/htmlbrowser.h index d9eff4afb..3fac84b11 100644 --- a/src/gui/rss/htmlbrowser.h +++ b/src/gui/rss/htmlbrowser.h @@ -38,6 +38,7 @@ class QNetworkReply; class HtmlBrowser final : public QTextBrowser { Q_OBJECT + Q_DISABLE_COPY_MOVE(HtmlBrowser) public: explicit HtmlBrowser(QWidget* parent = nullptr); diff --git a/src/gui/rss/rsswidget.h b/src/gui/rss/rsswidget.h index 01beebf81..444044457 100644 --- a/src/gui/rss/rsswidget.h +++ b/src/gui/rss/rsswidget.h @@ -46,6 +46,7 @@ namespace Ui class RSSWidget : public QWidget { Q_OBJECT + Q_DISABLE_COPY_MOVE(RSSWidget) public: RSSWidget(QWidget *parent); diff --git a/src/gui/shutdownconfirmdialog.h b/src/gui/shutdownconfirmdialog.h index 6912b5e55..b5d7f5d26 100644 --- a/src/gui/shutdownconfirmdialog.h +++ b/src/gui/shutdownconfirmdialog.h @@ -41,6 +41,7 @@ namespace Ui class ShutdownConfirmDialog final : public QDialog { Q_OBJECT + Q_DISABLE_COPY_MOVE(ShutdownConfirmDialog) public: ShutdownConfirmDialog(QWidget *parent, const ShutdownDialogAction &action); diff --git a/src/gui/tagfiltermodel.h b/src/gui/tagfiltermodel.h index 0b44a784d..4e264e7a7 100644 --- a/src/gui/tagfiltermodel.h +++ b/src/gui/tagfiltermodel.h @@ -45,6 +45,7 @@ namespace BitTorrent class TagFilterModel final : public QAbstractListModel { Q_OBJECT + Q_DISABLE_COPY_MOVE(TagFilterModel) public: explicit TagFilterModel(QObject *parent = nullptr); diff --git a/src/gui/tagfilterwidget.h b/src/gui/tagfilterwidget.h index 6689f4b39..d5be96cf0 100644 --- a/src/gui/tagfilterwidget.h +++ b/src/gui/tagfilterwidget.h @@ -33,6 +33,7 @@ class TagFilterWidget final : public QTreeView { Q_OBJECT + Q_DISABLE_COPY_MOVE(TagFilterWidget) public: explicit TagFilterWidget(QWidget *parent = nullptr); diff --git a/src/gui/torrentcontentfiltermodel.h b/src/gui/torrentcontentfiltermodel.h index a23f31c16..f475e1aee 100644 --- a/src/gui/torrentcontentfiltermodel.h +++ b/src/gui/torrentcontentfiltermodel.h @@ -38,6 +38,7 @@ class TorrentContentModel; class TorrentContentFilterModel final : public QSortFilterProxyModel { Q_OBJECT + Q_DISABLE_COPY_MOVE(TorrentContentFilterModel) public: TorrentContentFilterModel(QObject *parent = nullptr);