Skip to content

Commit

Permalink
Apply Q_DISABLE_COPY_MOVE macro in some widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
Petross404 committed Oct 20, 2021
1 parent 4ec0a07 commit 5f8519a
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 3 deletions.
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 &&w) = delete; \
Class &operator=(Class &&w) = 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
4 changes: 4 additions & 0 deletions src/widgets/ColorPicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace ColorPickerHelpers {
class ColorPickWidgetAbstract : public QWidget
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(ColorPickWidgetAbstract)

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

public:
explicit ColorPicker(QWidget *parent = nullptr);
~ColorPicker();
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/ColorThemeComboBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class ColorThemeComboBox : public QComboBox
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(ColorThemeComboBox)

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

0 comments on commit 5f8519a

Please sign in to comment.