]> OCCT Git - occt-copy.git/commitdiff
0025571: Avoid base Classes without virtual Destructors
authorabv <abv@opencascade.com>
Mon, 21 Sep 2015 13:38:01 +0000 (16:38 +0300)
committerkgv <kgv@opencascade.com>
Thu, 24 Sep 2015 11:14:22 +0000 (14:14 +0300)
Destructors of collection classes from NCollection and math_Function are made virtual to allow safe destruction by pointer to base class.

Destructors of classes HatchGen_IntersectionPoint, IntCurveSurface_Intersection, Intf_Interference, IntRes2d_Intersection are made protected to avoid possibility of destructing by pointer to corresponding base class.

17 files changed:
src/HatchGen/HatchGen_IntersectionPoint.cxx
src/HatchGen/HatchGen_IntersectionPoint.hxx
src/IntCurveSurface/IntCurveSurface_Intersection.hxx
src/IntRes2d/IntRes2d_Intersection.hxx
src/Intf/Intf_Interference.hxx
src/NCollection/NCollection_BaseList.hxx
src/NCollection/NCollection_BaseMap.hxx
src/NCollection/NCollection_BaseSequence.hxx
src/NCollection/NCollection_BaseVector.hxx
src/NCollection/NCollection_DataMap.hxx
src/NCollection/NCollection_IndexedDataMap.hxx
src/NCollection/NCollection_IndexedMap.hxx
src/NCollection/NCollection_List.hxx
src/NCollection/NCollection_Map.hxx
src/NCollection/NCollection_Sequence.hxx
src/NCollection/NCollection_Vector.hxx
src/math/math_Function.hxx

index 17e7884050de7011399d146ebf87e7da3fd69c39..b3305938e8f7bee803ae8c62adec097e7854237e 100644 (file)
@@ -32,16 +32,6 @@ HatchGen_IntersectionPoint::HatchGen_IntersectionPoint () :
 {
 }
 
-//=======================================================================
-// Function : ~HatchGen_IntersectionPoint
-// Purpose  : Destructor
-//=======================================================================
-
-HatchGen_IntersectionPoint::~HatchGen_IntersectionPoint()
-{
-}
-
-
 //=======================================================================
 // Function : SetIndex
 // Purpose  : Sets the index of the supporting curve.
index 6a6edcd0fa98693281050e425d3d2248697729f8..7c961d23a6e2017a1fc593f40480415b43c4dc70 100644 (file)
@@ -80,17 +80,16 @@ public:
   
   //! Dump of the point on element.
   Standard_EXPORT virtual void Dump (const Standard_Integer Index = 0) const = 0;
-  Standard_EXPORT virtual ~HatchGen_IntersectionPoint();
-
-
-
 
 protected:
-
   
   //! Creates an empty intersection point.
   Standard_EXPORT HatchGen_IntersectionPoint();
 
+  //! Destructor is protected for safer inheritance
+  ~HatchGen_IntersectionPoint() {}
+
+protected:
 
   Standard_Integer myIndex;
   Standard_Real myParam;
@@ -99,20 +98,6 @@ protected:
   TopAbs_State myAfter;
   Standard_Boolean mySegBeg;
   Standard_Boolean mySegEnd;
-
-
-private:
-
-
-
-
-
 };
 
-
-
-
-
-
-
 #endif // _HatchGen_IntersectionPoint_HeaderFile
index 109fcaf21ec79f4565ca15aa864aabc473af8b14..a81d4cbaeb87d843e35b98a86f1a621d61c96250 100644 (file)
@@ -68,15 +68,14 @@ public:
   //! Dump all the fields.
   Standard_EXPORT void Dump() const;
 
-
-
-
 protected:
-
   
   //! Empty Constructor;
   Standard_EXPORT IntCurveSurface_Intersection();
   
+  //! Destructor is protected, for safe inheritance
+  ~IntCurveSurface_Intersection() {}
+
   //! Internal method
   //! copy the <Inter> fields to <me>
   Standard_EXPORT void SetValues (const IntCurveSurface_Intersection& Inter);
index 441006294b4a17fc031fe76fd97c132feae9064f..ab39e3bf52b433b0a9a55bd7da031d3986339062 100644 (file)
@@ -86,6 +86,9 @@ protected:
     IntRes2d_Intersection();
   
     IntRes2d_Intersection(const IntRes2d_Intersection& Other);
+
+  //! Destructor is protected, for safe inheritance
+  ~IntRes2d_Intersection () {}
   
   Standard_EXPORT void SetValues (const IntRes2d_Intersection& Inter);
   
index 429ef7c479f6e397dd644c3b44eac528e6764aee..5231de61d001daf5a6f0d281ca2d93ab48513aea 100644 (file)
@@ -90,9 +90,12 @@ public:
 
 protected:
 
-  
+  //! Empty constructor
   Standard_EXPORT Intf_Interference(const Standard_Boolean Self);
   
+  //! Destructor is protected, for safer inheritance
+  ~Intf_Interference () {}
+
   //! Only one argument for the intersection.
   Standard_EXPORT void SelfInterference (const Standard_Boolean Self);
 
index d1c698b1a119fe33483073aab7f1a713c669af36..e98a2c335241d05719135765eb5896beec60ffaa 100644 (file)
@@ -119,6 +119,11 @@ public:
   const Handle(NCollection_BaseAllocator)& Allocator() const 
   { return myAllocator; }
 
+  // ******** Destructor
+  // Purpose: defines virtual interface
+  virtual ~NCollection_BaseList (void)
+  {}
+
  protected:
   // --------- PROTECTED METHODS ----------
 
index 94740f3a046708295d58d441e084132b7308b1d1..a84362bd743cf7d5316e9d6a9d7a9a44b8fcda3a 100644 (file)
@@ -166,6 +166,9 @@ public:
     myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
   }
 
+  //! Destructor
+  virtual ~NCollection_BaseMap() {}
+
   //! BeginResize
   Standard_EXPORT Standard_Boolean BeginResize 
     (const Standard_Integer  NbBuckets,
index d2a2bbc2297e69b1f7a363e2c5af8849c163ee4b..c4a5bc794e0f5be41dddc46004387e318fda2417 100644 (file)
@@ -115,6 +115,9 @@ public:
     myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
   }
 
+  //! Destructor
+  virtual ~NCollection_BaseSequence() {}
+
   Standard_EXPORT void   ClearSeq    (NCollection_DelSeqNode fDel);
   Standard_EXPORT void   PAppend     (NCollection_SeqNode *);
   Standard_EXPORT void   PAppend     (NCollection_BaseSequence& S);
index 7e8be304c8790e1f287fea15f444a06389d5b743..9b32c0c59b66139813123fa0a7c720d7717f0bc8 100755 (executable)
@@ -184,6 +184,9 @@ protected: //! @name protected methods
     myData = allocMemBlocks (myCapacity);
   }
 
+  //! Destructor
+  virtual ~NCollection_BaseVector() {}
+
   //! @return pointer to memory where to put the new item
   Standard_EXPORT void* expandV (const Standard_Integer theIndex);
 
index b223e3b0482bf8e951c37b43510347b468f67b48..8756f5b2c22fd3da6f37a4c0802d94c2a98a59e8 100644 (file)
@@ -359,7 +359,7 @@ class NCollection_DataMap : public NCollection_BaseMap
   }
 
   //! Destructor
-  ~NCollection_DataMap (void)
+  virtual ~NCollection_DataMap (void)
   { Clear(); }
 
   //! Size
index 05d4e32cb4e5492c9f28a66dd0d00ed6c5114c0b..09b60ad6fdd132ac234041a8a88f18fe5a215b48 100644 (file)
@@ -593,7 +593,7 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
   }
 
   //! Destructor
-  ~NCollection_IndexedDataMap (void)
+  virtual ~NCollection_IndexedDataMap (void)
   { Clear(); }
 
   //! Size
index 29628b90aa8953b5137467abbe1bbf95a5dc28cc..f7ac9ee9e5b1d0c136c12af159cda581641c66f7 100644 (file)
@@ -454,7 +454,7 @@ class NCollection_IndexedMap : public NCollection_BaseMap
   }
 
   //! Destructor
-  ~NCollection_IndexedMap (void)
+  virtual ~NCollection_IndexedMap (void)
   { Clear(); }
 
   //! Size
index b525603371219dc8871b275a5c26ebdf51a32366..39a4280d09463abd5311b188f60689bb8d31c018 100644 (file)
@@ -271,7 +271,7 @@ public:
   { PReverse(); }
 
   //! Destructor - clears the List
-  ~NCollection_List (void)
+  virtual ~NCollection_List (void)
   { Clear(); }
 
  private:
index 6424858fe24c6e09df0fd8e940619a9d95ab70a0..16dde63fcc5c885bac83a61e0273928c931599c5 100644 (file)
@@ -290,7 +290,7 @@ class NCollection_Map : public NCollection_BaseMap
   }
 
   //! Destructor
-  ~NCollection_Map (void)
+  virtual ~NCollection_Map (void)
   { Clear(); }
 
   //! Size
index f9f8fed2815a596084f3e6f07ff7f3df9c648ef1..f50896cf022fe16459314d26fae9b0636137b509 100644 (file)
@@ -325,7 +325,7 @@ public:
   { ChangeValue (theIndex) = theItem; }
 
   // ******** Destructor - clears the Sequence
-  ~NCollection_Sequence (void)
+  virtual ~NCollection_Sequence (void)
   { Clear(); }
 
  private:
index fb56faeda4cd93584c401ad214b61dfa80de3c29..e7b89df5c289a93353089a9ce693ac0ff33c55af 100755 (executable)
@@ -165,7 +165,7 @@ public: //! @name public methods
   }
 
   //! Destructor
-  ~NCollection_Vector()
+  virtual ~NCollection_Vector()
   {
     for (Standard_Integer anItemIter = 0; anItemIter < myCapacity; ++anItemIter)
     {
index 628fbb201ca25131b5891a9c850813aa7c1a21d2..81064a2d0648899b6d06888bf90f41a92e2ce70a 100644 (file)
@@ -34,6 +34,8 @@ public:
 
   DEFINE_STANDARD_ALLOC
 
+  //! Virtual destructor, for safe inheritance
+  virtual ~math_Function () {}
   
   //! Computes the value of the function <F> for a given value of
   //! variable <X>.
@@ -56,28 +58,6 @@ public:
   //! to save the current state of the function and to return
   //! an Integer that allows retrieval of the state.
   Standard_EXPORT virtual Standard_Integer GetStateNumber();
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
 };
 
-
-
-
-
-
-
 #endif // _math_Function_HeaderFile