From 30f05d8fc9ae6e1df273b38b98bb2bd8bf7dd901 Mon Sep 17 00:00:00 2001 From: Norbert Wenzel Date: Sun, 20 Oct 2019 13:38:39 +0200 Subject: [PATCH 1/2] Add virtual default dtor to base class TrivialEar has data members and virtual functions, but no virtual destructor. Two subclasses (MinimalWeightEar & SelfIntersectionEar) exist, but they do not add any new data members. So deleting through any pointer should be okay, but to be sure and silence compiler warnings add the virtual dtor to the base class. This ensures all subclasses are theoretically allowed to add new data members that will get destructed, regardless of the pointer type used for destruction. --- vcg/complex/algorithms/hole.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcg/complex/algorithms/hole.h b/vcg/complex/algorithms/hole.h index 064d1807..ecb2256b 100644 --- a/vcg/complex/algorithms/hole.h +++ b/vcg/complex/algorithms/hole.h @@ -100,6 +100,8 @@ public: ComputeQuality(); ComputeAngle(); } + // enforce virtual dtor for this class and all subclasses + virtual ~TrivialEar() = default; /// Compute the angle of the two edges of the ear. // it tries to make the computation in a precision safe way. From d0c135e0e0ee98ee9a87d25506f9562d0d3530bf Mon Sep 17 00:00:00 2001 From: Norbert Wenzel Date: Thu, 24 Oct 2019 22:23:45 +0200 Subject: [PATCH 2/2] Mark internal class as `final` The internal `Element` class implements the pure virtual interface `IElement` which has no virtual destructor. `Element` has data members but is deleted through an `Element*` so all members are destructed correctly. To convince the compiler this is all fine and to prevent the (unlikely) case of someone inheriting from `Element` mark the class as `final`. --- wrap/openfbx/src/ofbx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrap/openfbx/src/ofbx.cpp b/wrap/openfbx/src/ofbx.cpp index a6e23236..8679bd6d 100644 --- a/wrap/openfbx/src/ofbx.cpp +++ b/wrap/openfbx/src/ofbx.cpp @@ -355,7 +355,7 @@ struct Property : IElementProperty }; -struct Element : IElement +struct Element final : IElement { IElement* getFirstChild() const override { return child; } IElement* getSibling() const override { return sibling; }