From add3ec71d280a6714790970fc6a2ec622c9be97c Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Wed, 26 Jul 2023 15:08:21 +0200 Subject: [PATCH] Cleanup: Address clang-tidy warnings in UI views Unused header warning and `modernize-use-override` warnings. I would like to selectively disable warnings about redundant `virtual` and `override` keywords, since both together are useful (`override` enables important compiler warnings that can avoid bugs, `virtual` helps quickly identifying API functions available for overriding). But this doesn't seem to be possible, only all of `modernize-use-override` can be disabled, so simply keep the `virtual` but comment it out. --- source/blender/editors/include/UI_grid_view.hh | 8 ++++---- source/blender/editors/include/UI_tree_view.hh | 18 ++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/source/blender/editors/include/UI_grid_view.hh b/source/blender/editors/include/UI_grid_view.hh index a0147112fe4..21493155bda 100644 --- a/source/blender/editors/include/UI_grid_view.hh +++ b/source/blender/editors/include/UI_grid_view.hh @@ -44,7 +44,7 @@ class AbstractGridViewItem : public AbstractViewItem { uiButViewItem *view_item_but_ = nullptr; public: - virtual ~AbstractGridViewItem() = default; + /* virtual */ ~AbstractGridViewItem() override = default; virtual void build_grid_tile(uiLayout &layout) const = 0; @@ -54,7 +54,7 @@ class AbstractGridViewItem : public AbstractViewItem { AbstractGridViewItem(StringRef identifier); /** See AbstractViewItem::matches(). */ - virtual bool matches(const AbstractViewItem &other) const override; + /* virtual */ bool matches(const AbstractViewItem &other) const override; /** Called when the item's state changes from inactive to active. */ virtual void on_activate(); @@ -64,7 +64,7 @@ class AbstractGridViewItem : public AbstractViewItem { */ virtual std::optional should_be_active() const; - virtual std::unique_ptr create_item_drop_target() final; + /* virtual */ std::unique_ptr create_item_drop_target() final; virtual std::unique_ptr create_drop_target(); /** @@ -111,7 +111,7 @@ class AbstractGridView : public AbstractView { public: AbstractGridView(); - virtual ~AbstractGridView() = default; + /* virtual */ ~AbstractGridView() override = default; using ItemIterFn = FunctionRef; void foreach_item(ItemIterFn iter_fn) const; diff --git a/source/blender/editors/include/UI_tree_view.hh b/source/blender/editors/include/UI_tree_view.hh index 2d66d0feb79..be074d816da 100644 --- a/source/blender/editors/include/UI_tree_view.hh +++ b/source/blender/editors/include/UI_tree_view.hh @@ -15,8 +15,6 @@ #include #include -#include "DNA_defs.h" - #include "BLI_function_ref.hh" #include "BLI_math_vector_types.hh" #include "BLI_vector.hh" @@ -119,7 +117,7 @@ class AbstractTreeView : public AbstractView, public TreeViewItemContainer { friend class TreeViewItemDropTarget; public: - virtual ~AbstractTreeView() = default; + /* virtual */ ~AbstractTreeView() override = default; void draw_overlays(const ARegion ®ion) const override; @@ -186,11 +184,11 @@ class AbstractTreeViewItem : public AbstractViewItem, public TreeViewItemContain std::string label_{}; public: - virtual ~AbstractTreeViewItem() = default; + /* virtual */ ~AbstractTreeViewItem() override = default; virtual void build_row(uiLayout &row) = 0; - virtual std::unique_ptr create_item_drop_target() final; + std::unique_ptr create_item_drop_target() final; virtual std::unique_ptr create_drop_target(); AbstractTreeView &get_tree_view() const; @@ -222,9 +220,9 @@ class AbstractTreeViewItem : public AbstractViewItem, public TreeViewItemContain virtual std::optional should_be_active() const; /** See AbstractViewItem::get_rename_string(). */ - virtual StringRef get_rename_string() const override; + /* virtual */ StringRef get_rename_string() const override; /** See AbstractViewItem::rename(). */ - virtual bool rename(StringRefNull new_name) override; + /* virtual */ bool rename(StringRefNull new_name) override; /** * Return whether the item can be collapsed. Used to disable collapsing for items with children. @@ -233,10 +231,10 @@ class AbstractTreeViewItem : public AbstractViewItem, public TreeViewItemContain virtual bool supports_collapsing() const; /** See #AbstractViewItem::matches(). */ - virtual bool matches(const AbstractViewItem &other) const override; + /* virtual */ bool matches(const AbstractViewItem &other) const override; /** See #AbstractViewItem::update_from_old(). */ - virtual void update_from_old(const AbstractViewItem &old) override; + /* virtual */ void update_from_old(const AbstractViewItem &old) override; /** * Compare this item to \a other to check if they represent the same data. @@ -354,7 +352,7 @@ class TreeViewItemDropTarget : public DropTargetInterface { TreeViewItemDropTarget(AbstractTreeView &view, DropBehavior behavior = DropBehavior::Insert); std::optional choose_drop_location(const ARegion ®ion, - const wmEvent &event) const; + const wmEvent &event) const override; /** Request the view the item is registered for as type #ViewType. Throws a `std::bad_cast` * exception if the view is not of the requested type. */