From 0f349a7a488a508a4d2d8b47e50edb26d54d3e7e Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Thu, 18 Feb 2016 06:08:27 +0100 Subject: [PATCH] Fixed a bug in the cleanup of sky_sphere transforms. Also cleaned up cleanup (no pun intended) of object transforms along the way. --- source/core/scene/atmosphere.cpp | 6 ++++++ source/core/scene/atmosphere.h | 2 +- source/core/scene/object.cpp | 5 +++++ source/core/scene/object.h | 2 +- source/core/shape/blob.cpp | 1 - source/core/shape/box.cpp | 4 +--- source/core/shape/cone.cpp | 4 +--- source/core/shape/disc.cpp | 4 +--- source/core/shape/fractal.cpp | 4 +--- source/core/shape/heightfield.cpp | 2 -- source/core/shape/isosurface.cpp | 1 - source/core/shape/lathe.cpp | 2 -- source/core/shape/mesh.cpp | 2 -- source/core/shape/ovus.cpp | 4 +--- source/core/shape/parametric.cpp | 1 - source/core/shape/plane.cpp | 4 +--- source/core/shape/polygon.cpp | 2 -- source/core/shape/polynomial.cpp | 2 -- source/core/shape/prism.cpp | 2 -- source/core/shape/sor.cpp | 2 -- source/core/shape/sphere.cpp | 1 - source/core/shape/spheresweep.cpp | 2 -- source/core/shape/superellipsoid.cpp | 4 +--- source/core/shape/torus.cpp | 4 +--- source/core/shape/truetype.cpp | 4 +--- 25 files changed, 22 insertions(+), 49 deletions(-) diff --git a/source/core/scene/atmosphere.cpp b/source/core/scene/atmosphere.cpp index 290fa406b..c4df5fb46 100644 --- a/source/core/scene/atmosphere.cpp +++ b/source/core/scene/atmosphere.cpp @@ -452,6 +452,12 @@ void Destroy_Skysphere(SKYSPHERE *Skysphere) delete Skysphere; } +Skysphere_Struct::~Skysphere_Struct() +{ + for (vector::iterator i = Pigments.begin(); i != Pigments.end(); ++ i) + delete *i; + Destroy_Transform(Trans); +} /***************************************************************************** diff --git a/source/core/scene/atmosphere.h b/source/core/scene/atmosphere.h index c3ec71c9c..f6668a6b7 100644 --- a/source/core/scene/atmosphere.h +++ b/source/core/scene/atmosphere.h @@ -96,7 +96,7 @@ struct Rainbow_Struct struct Skysphere_Struct { Skysphere_Struct() : Trans(NULL) {} - ~Skysphere_Struct() { for (vector::iterator i = Pigments.begin(); i != Pigments.end(); ++ i) delete *i; if (Trans) POV_FREE(Trans); } + ~Skysphere_Struct(); MathColour Emission; ///< Brightness adjustment. vector Pigments; ///< Pigment(s) to use. TRANSFORM * Trans; ///< Skysphere transformation. diff --git a/source/core/scene/object.cpp b/source/core/scene/object.cpp index 8a984af2c..1302b1eb2 100644 --- a/source/core/scene/object.cpp +++ b/source/core/scene/object.cpp @@ -824,6 +824,11 @@ void Destroy_Object(ObjectPtr Object) } } +ObjectBase::~ObjectBase() +{ + Destroy_Transform(Trans); +} + /***************************************************************************** * diff --git a/source/core/scene/object.h b/source/core/scene/object.h index 0c10743a3..1c809f5d6 100644 --- a/source/core/scene/object.h +++ b/source/core/scene/object.h @@ -206,7 +206,7 @@ class ObjectBase o.LLights.clear(); } } - virtual ~ObjectBase() { } + virtual ~ObjectBase(); virtual ObjectPtr Copy() = 0; diff --git a/source/core/shape/blob.cpp b/source/core/shape/blob.cpp index 1f8ad53c6..6d28c5200 100644 --- a/source/core/shape/blob.cpp +++ b/source/core/shape/blob.cpp @@ -2187,7 +2187,6 @@ Blob_List_Struct *Blob::Create_Blob_List_Element() Blob::~Blob() { - Destroy_Transform(Trans); for (vector::iterator i = Element_Texture.begin(); i != Element_Texture.end(); ++i) Destroy_Textures(*i); if (Data != NULL) diff --git a/source/core/shape/box.cpp b/source/core/shape/box.cpp index 775cefaf2..d2e37fcc3 100644 --- a/source/core/shape/box.cpp +++ b/source/core/shape/box.cpp @@ -903,9 +903,7 @@ ObjectPtr Box::Copy() ******************************************************************************/ Box::~Box() -{ - Destroy_Transform(Trans); -} +{} diff --git a/source/core/shape/cone.cpp b/source/core/shape/cone.cpp index 221e1761b..4bf486877 100644 --- a/source/core/shape/cone.cpp +++ b/source/core/shape/cone.cpp @@ -883,9 +883,7 @@ void Cone::Compute_Cylinder_Data() ******************************************************************************/ Cone::~Cone() -{ - Destroy_Transform(Trans); -} +{} diff --git a/source/core/shape/disc.cpp b/source/core/shape/disc.cpp index 1ededabf8..311a10067 100644 --- a/source/core/shape/disc.cpp +++ b/source/core/shape/disc.cpp @@ -501,9 +501,7 @@ ObjectPtr Disc::Copy() ******************************************************************************/ Disc::~Disc() -{ - Destroy_Transform(Trans); -} +{} diff --git a/source/core/shape/fractal.cpp b/source/core/shape/fractal.cpp index a88374383..be64f0e2c 100644 --- a/source/core/shape/fractal.cpp +++ b/source/core/shape/fractal.cpp @@ -697,9 +697,7 @@ ObjectPtr Fractal::Copy() ******************************************************************************/ Fractal::~Fractal() -{ - Destroy_Transform(Trans); -} +{} /***************************************************************************** * diff --git a/source/core/shape/heightfield.cpp b/source/core/shape/heightfield.cpp index 013753247..74fc767f7 100644 --- a/source/core/shape/heightfield.cpp +++ b/source/core/shape/heightfield.cpp @@ -1297,8 +1297,6 @@ HField::~HField() { int i; - Destroy_Transform(Trans); - if (--(Data->References) == 0) { if (Data->Map != NULL) diff --git a/source/core/shape/isosurface.cpp b/source/core/shape/isosurface.cpp index 59a6902c7..302c93993 100644 --- a/source/core/shape/isosurface.cpp +++ b/source/core/shape/isosurface.cpp @@ -619,7 +619,6 @@ IsoSurface::~IsoSurface() if(--mginfo->refcnt == 0) POV_FREE(mginfo); delete Function; - Destroy_Transform(Trans); } /***************************************************************************** diff --git a/source/core/shape/lathe.cpp b/source/core/shape/lathe.cpp index 63beeacc6..309f973d1 100644 --- a/source/core/shape/lathe.cpp +++ b/source/core/shape/lathe.cpp @@ -862,8 +862,6 @@ ObjectPtr Lathe::Copy() Lathe::~Lathe() { - Destroy_Transform(Trans); - if (--(Spline->References) == 0) { Destroy_BCyl(Spline->BCyl); diff --git a/source/core/shape/mesh.cpp b/source/core/shape/mesh.cpp index c86c657b1..c158342c8 100644 --- a/source/core/shape/mesh.cpp +++ b/source/core/shape/mesh.cpp @@ -705,8 +705,6 @@ Mesh::~Mesh() { MeshIndex i; - Destroy_Transform(Trans); - /* NK 1999 move texture outside of data block */ if (Textures != NULL) { diff --git a/source/core/shape/ovus.cpp b/source/core/shape/ovus.cpp index f1610bb01..07ea37a9f 100644 --- a/source/core/shape/ovus.cpp +++ b/source/core/shape/ovus.cpp @@ -774,9 +774,7 @@ ObjectPtr Ovus::Copy() ******************************************************************************/ Ovus::~Ovus() -{ - Destroy_Transform(Trans); -} +{} diff --git a/source/core/shape/parametric.cpp b/source/core/shape/parametric.cpp index 285555b55..f3aaa9c64 100644 --- a/source/core/shape/parametric.cpp +++ b/source/core/shape/parametric.cpp @@ -684,7 +684,6 @@ ObjectPtr Parametric::Copy() Parametric::~Parametric() { - Destroy_Transform(Trans); delete Function[0]; delete Function[1]; delete Function[2]; diff --git a/source/core/shape/plane.cpp b/source/core/shape/plane.cpp index 65130033f..5af9d11c0 100644 --- a/source/core/shape/plane.cpp +++ b/source/core/shape/plane.cpp @@ -572,9 +572,7 @@ ObjectPtr Plane::Copy() ******************************************************************************/ Plane::~Plane() -{ - Destroy_Transform(Trans); -} +{} diff --git a/source/core/shape/polygon.cpp b/source/core/shape/polygon.cpp index a60d48dae..e818506eb 100644 --- a/source/core/shape/polygon.cpp +++ b/source/core/shape/polygon.cpp @@ -594,8 +594,6 @@ Polygon::~Polygon() POV_FREE (Data); } - - Destroy_Transform(Trans); } diff --git a/source/core/shape/polynomial.cpp b/source/core/shape/polynomial.cpp index 81d850a5b..d94c51883 100644 --- a/source/core/shape/polynomial.cpp +++ b/source/core/shape/polynomial.cpp @@ -1455,8 +1455,6 @@ ObjectPtr Poly::Copy() Poly::~Poly() { - Destroy_Transform(Trans); - POV_FREE(Coeffs); } diff --git a/source/core/shape/prism.cpp b/source/core/shape/prism.cpp index d3a9b19b4..cc8cbbaab 100644 --- a/source/core/shape/prism.cpp +++ b/source/core/shape/prism.cpp @@ -1031,8 +1031,6 @@ ObjectPtr Prism::Copy() Prism::~Prism() { - Destroy_Transform(Trans); - if (--(Spline->References) == 0) { POV_FREE(Spline->Entry); diff --git a/source/core/shape/sor.cpp b/source/core/shape/sor.cpp index 0c80da375..8ef44752c 100644 --- a/source/core/shape/sor.cpp +++ b/source/core/shape/sor.cpp @@ -860,8 +860,6 @@ ObjectPtr Sor::Copy() Sor::~Sor() { - Destroy_Transform(Trans); - if (--(Spline->References) == 0) { Destroy_BCyl(Spline->BCyl); diff --git a/source/core/shape/sphere.cpp b/source/core/shape/sphere.cpp index 3791198a0..8d141dafe 100644 --- a/source/core/shape/sphere.cpp +++ b/source/core/shape/sphere.cpp @@ -649,7 +649,6 @@ Sphere::~Sphere() Debug_Info("}\n"); #endif - Destroy_Transform(Trans); Destroy_Transform(UV_Trans); } diff --git a/source/core/shape/spheresweep.cpp b/source/core/shape/spheresweep.cpp index b65b5d2fe..5895e2e54 100644 --- a/source/core/shape/spheresweep.cpp +++ b/source/core/shape/spheresweep.cpp @@ -1290,8 +1290,6 @@ void SphereSweep::Transform(const TRANSFORM *tr) SphereSweep::~SphereSweep() { - Destroy_Transform(Trans); - POV_FREE(Modeling_Sphere); POV_FREE(Sphere); POV_FREE(Segment); diff --git a/source/core/shape/superellipsoid.cpp b/source/core/shape/superellipsoid.cpp index 56b94cda7..4e75b4968 100644 --- a/source/core/shape/superellipsoid.cpp +++ b/source/core/shape/superellipsoid.cpp @@ -742,9 +742,7 @@ ObjectPtr Superellipsoid::Copy() ******************************************************************************/ Superellipsoid::~Superellipsoid() -{ - Destroy_Transform(Trans); -} +{} diff --git a/source/core/shape/torus.cpp b/source/core/shape/torus.cpp index 58b8ccc06..c53a07f19 100644 --- a/source/core/shape/torus.cpp +++ b/source/core/shape/torus.cpp @@ -800,9 +800,7 @@ ObjectPtr SpindleTorus::Copy() ******************************************************************************/ Torus::~Torus() -{ - Destroy_Transform(Trans); -} +{} SpindleTorus::~SpindleTorus() {} diff --git a/source/core/shape/truetype.cpp b/source/core/shape/truetype.cpp index 0504c1a3f..8c5165a20 100644 --- a/source/core/shape/truetype.cpp +++ b/source/core/shape/truetype.cpp @@ -2943,9 +2943,7 @@ TrueType::TrueType() : ObjectBase(TTF_OBJECT) } TrueType::~TrueType() -{ - Destroy_Transform(Trans); -} +{}