Add final modifier to ToolLoopImpl to avoid clang-tidy warning

The warning is about using a virtual member function in the destructor
where it can be overridden by a derived class so in this case the
derived version wouldn't be called.

Just testing clang-tidy to see if we can add something in the CI.
This commit is contained in:
David Capello 2024-02-26 15:32:40 -03:00
parent 5dbaa295c5
commit a2b294b0fe

View File

@ -452,8 +452,8 @@ protected:
//////////////////////////////////////////////////////////////////////
// For drawing
class ToolLoopImpl : public ToolLoopBase,
public EditorObserver {
class ToolLoopImpl final : public ToolLoopBase,
public EditorObserver {
Context* m_context;
bool m_filled;
bool m_previewFilled;
@ -592,6 +592,9 @@ public:
m_editor->remove_observer(this);
#endif
// getSrcImage() is a virtual member function but ToolLoopImpl is
// marked as final to avoid not calling a derived version from
// this destructor.
if (m_floodfillSrcImage != getSrcImage())
delete m_floodfillSrcImage;
}
@ -954,7 +957,7 @@ tools::ToolLoop* create_tool_loop_for_script(
#ifdef ENABLE_UI
class PreviewToolLoopImpl : public ToolLoopBase {
class PreviewToolLoopImpl final : public ToolLoopBase {
Image* m_image;
public: