Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Q_DISABLE_COPY_MOVE macro in some widgets #2814

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/core/CutterCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#endif // Q_OS_WIN

// Rizin list iteration macros
#define CutterRzListForeach(list, it, type, x) \
#define CutterRzListForeach(list, it, type, x) \
if (list) \
for (it = list->head; it && ((x = static_cast<type *>(it->data))); it = it->n)

#define CutterRzVectorForeach(vec, it, type) \
#define CutterRzVectorForeach(vec, it, type) \
if ((vec) && (vec)->a) \
for (it = (type *)(vec)->a; \
(char *)it != (char *)(vec)->a + ((vec)->len * (vec)->elem_size); \
Expand Down Expand Up @@ -74,4 +74,19 @@ inline QString RzHexString(RVA size)
# define CUTTER_DEPRECATED(msg)
#endif

/**
* @brief Since Qt versions < 5.13 don't define the Q_DISABLE_COPY_MOVE
* macro, we define it here. This check and this macro definition will
* be deprecated when Cutter moves to a greater than 5.13.0 Qt version.
*/
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
# define Q_DISABLE_MOVE(Class) \
Class(Class &&) = delete; \
Class &operator=(Class &&) = delete;

# define Q_DISABLE_COPY_MOVE(Class) \
Q_DISABLE_COPY(Class) \
Q_DISABLE_MOVE(Class)
#endif

#endif // CUTTERCORE_H
2 changes: 2 additions & 0 deletions src/widgets/AddressableDockWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class CutterSeekable;
class AddressableDockWidget : public CutterDockWidget
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(AddressableDockWidget)

public:
AddressableDockWidget(MainWindow *parent);
~AddressableDockWidget() override {}
Expand Down
1 change: 1 addition & 0 deletions src/widgets/BacktraceWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class BacktraceWidget;
class BacktraceWidget : public CutterDockWidget
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(BacktraceWidget)

public:
explicit BacktraceWidget(MainWindow *main);
Expand Down
3 changes: 3 additions & 0 deletions src/widgets/BoolToggleDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

class CUTTER_EXPORT BoolTogggleDelegate : public QStyledItemDelegate
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(BoolTogggleDelegate)

public:
BoolTogggleDelegate(QObject *parent = nullptr);

Expand Down
3 changes: 3 additions & 0 deletions src/widgets/BreakpointWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class BreakpointWidget;
class BreakpointModel : public AddressableItemModel<QAbstractListModel>
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(BreakpointModel)

friend BreakpointWidget;

Expand Down Expand Up @@ -60,6 +61,7 @@ class BreakpointModel : public AddressableItemModel<QAbstractListModel>
class BreakpointProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(BreakpointProxyModel)

public:
BreakpointProxyModel(BreakpointModel *sourceModel, QObject *parent = nullptr);
Expand All @@ -68,6 +70,7 @@ class BreakpointProxyModel : public AddressableFilterProxyModel
class BreakpointWidget : public CutterDockWidget
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(BreakpointWidget)

public:
explicit BreakpointWidget(MainWindow *main);
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/CallGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class MainWindow;
class CallGraphView : public SimpleTextGraphView
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(CallGraphView)

public:
CallGraphView(CutterDockWidget *parent, MainWindow *main, bool global);
void showExportDialog() override;
Expand Down
5 changes: 5 additions & 0 deletions src/widgets/ClassesWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class ClassesWidget;
*/
class ClassesModel : public QAbstractItemModel
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(ClassesModel)

public:
enum Columns { NAME = 0, TYPE, OFFSET, VTABLE, COUNT };

Expand Down Expand Up @@ -72,6 +75,7 @@ Q_DECLARE_METATYPE(ClassesModel::RowType)
class BinClassesModel : public ClassesModel
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(BinClassesModel)

private:
QList<BinClassDescription> classes;
Expand All @@ -93,6 +97,7 @@ class BinClassesModel : public ClassesModel
class AnalysisClassesModel : public ClassesModel
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(AnalysisClassesModel)

private:
/**
Expand Down
7 changes: 7 additions & 0 deletions src/widgets/ColorPicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace ColorPickerHelpers {
class ColorPickWidgetAbstract : public QWidget
{
Q_OBJECT

public:
ColorPickWidgetAbstract(QWidget *parent = nullptr) : QWidget(parent) {}
virtual ~ColorPickWidgetAbstract() {}
Expand All @@ -37,6 +38,7 @@ class ColorPicker;
class ColorPicker : public ColorPickerHelpers::ColorPickWidgetAbstract
{
Q_OBJECT

public:
explicit ColorPicker(QWidget *parent = nullptr);
~ColorPicker();
Expand Down Expand Up @@ -95,6 +97,7 @@ namespace ColorPickerHelpers {
class ColorPickerWidget : public ColorPickWidgetAbstract
{
Q_OBJECT

public:
ColorPickerWidget(QWidget *parent = nullptr);

Expand All @@ -119,6 +122,7 @@ class ColorPickerWidget : public ColorPickWidgetAbstract
class ColorShowWidget : public ColorPickWidgetAbstract
{
Q_OBJECT

public:
explicit ColorShowWidget(QWidget *parent = nullptr);

Expand All @@ -135,6 +139,7 @@ class ColorShowWidget : public ColorPickWidgetAbstract
class ColorPickArea : public ColorPickerWidget
{
Q_OBJECT

public:
explicit ColorPickArea(QWidget *parent = nullptr);

Expand All @@ -152,6 +157,7 @@ class ColorPickArea : public ColorPickerWidget
class AlphaChannelBar : public ColorPickerWidget
{
Q_OBJECT

public:
AlphaChannelBar(QWidget *parent = nullptr) : ColorPickerWidget(parent) {}

Expand All @@ -173,6 +179,7 @@ class AlphaChannelBar : public ColorPickerWidget
class ColorValueBar : public ColorPickerWidget
{
Q_OBJECT

public:
ColorValueBar(QWidget *parent = nullptr) : ColorPickerWidget(parent) {}

Expand Down
1 change: 1 addition & 0 deletions src/widgets/ColorThemeComboBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class ColorThemeComboBox : public QComboBox
{
Q_OBJECT

public:
explicit ColorThemeComboBox(QWidget *parent = nullptr);

Expand Down
6 changes: 6 additions & 0 deletions src/widgets/ColorThemeListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class ColorSettingsModel;
class ColorThemeListView : public QListView
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(ColorThemeListView)

public:
ColorThemeListView(QWidget *parent = nullptr);
virtual ~ColorThemeListView() override {}
Expand Down Expand Up @@ -56,6 +58,8 @@ private slots:
class ColorSettingsModel : public QAbstractListModel
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(ColorSettingsModel)

public:
ColorSettingsModel(QObject *parent = nullptr);
virtual ~ColorSettingsModel() override {}
Expand All @@ -81,6 +85,8 @@ class ColorSettingsModel : public QAbstractListModel
class ColorOptionDelegate : public QStyledItemDelegate
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(ColorOptionDelegate)

public:
ColorOptionDelegate(QObject *parent = nullptr);
~ColorOptionDelegate() override {}
Expand Down
1 change: 1 addition & 0 deletions src/widgets/ComboQuickFilterView.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ComboQuickFilterView;
class CUTTER_EXPORT ComboQuickFilterView : public QWidget
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(ComboQuickFilterView)

public:
explicit ComboQuickFilterView(QWidget *parent = nullptr);
Expand Down
3 changes: 3 additions & 0 deletions src/widgets/CommentsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct CommentGroup
class CommentsModel : public AddressableItemModel<>
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(CommentsModel)

friend CommentsWidget;

Expand Down Expand Up @@ -61,6 +62,7 @@ class CommentsModel : public AddressableItemModel<>
class CommentsProxyModel : public AddressableFilterProxyModel
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(CommentsProxyModel)

public:
CommentsProxyModel(CommentsModel *sourceModel, QObject *parent = nullptr);
Expand All @@ -73,6 +75,7 @@ class CommentsProxyModel : public AddressableFilterProxyModel
class CommentsWidget : public ListDockWidget
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(CommentsWidget)

public:
explicit CommentsWidget(MainWindow *main);
Expand Down
1 change: 1 addition & 0 deletions src/widgets/ConsoleWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ConsoleWidget;
class ConsoleWidget : public CutterDockWidget
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(ConsoleWidget)

public:
explicit ConsoleWidget(MainWindow *main);
Expand Down
1 change: 1 addition & 0 deletions src/widgets/CutterDockWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MainWindow;
class CUTTER_EXPORT CutterDockWidget : public QDockWidget
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(CutterDockWidget)

public:
CUTTER_DEPRECATED("Action will be ignored. Use CutterDockWidget(MainWindow*) instead.")
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/CutterGraphView.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
class CutterGraphView : public GraphView
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(CutterGraphView)

public:
CutterGraphView(QWidget *parent);
virtual bool event(QEvent *event) override;
Expand Down
1 change: 1 addition & 0 deletions src/widgets/CutterTreeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CutterTreeView;
class CUTTER_EXPORT CutterTreeView : public QTreeView
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(CutterTreeView)

public:
explicit CutterTreeView(QWidget *parent = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/CutterTreeWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class MainWindow;

class CUTTER_EXPORT CutterTreeWidget : public QObject
{

Q_OBJECT
Q_DISABLE_COPY_MOVE(CutterTreeWidget)

public:
explicit CutterTreeWidget(QObject *parent = nullptr);
Expand Down
15 changes: 0 additions & 15 deletions src/widgets/SdbWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@ class SdbWidget;
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:
Expand Down