Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-05-15 02:51:11 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-05-15 02:51:11 +0400
commit50c46fb9b3d1c6c423c0e6bf90a1bbc2e571c4bd (patch)
treea5309d7658605dfae9c46001c60496eedbee1e76 /source/blender
parent628bde206ff4bb35ecd6ff510211086c986dd9ed (diff)
Further fix for memory leaks in Freestyle Python API components:
- StrokeAttribute thickness setter - BezierCurve (used from within BezierCurveShader) - Smoother (used from within SmoothingShader)
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/freestyle/intern/geometry/Bezier.cpp5
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp13
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp7
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h2
4 files changed, 19 insertions, 8 deletions
diff --git a/source/blender/freestyle/intern/geometry/Bezier.cpp b/source/blender/freestyle/intern/geometry/Bezier.cpp
index e69830f3529..b9099df9a68 100644
--- a/source/blender/freestyle/intern/geometry/Bezier.cpp
+++ b/source/blender/freestyle/intern/geometry/Bezier.cpp
@@ -106,6 +106,11 @@ BezierCurve::BezierCurve(vector<Vec2d>& iPoints, double error)
BezierCurve::~BezierCurve()
{
+ if (!_Segments.empty()) {
+ vector<BezierCurveSegment*>::iterator v, vend;
+ for (v = _Segments.begin(), vend = _Segments.end(); v != vend; ++v)
+ delete *v;
+ }
if (_currentSegment)
delete _currentSegment;
}
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
index eb175eb7bca..e17f16a2fa7 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
@@ -526,13 +526,12 @@ static PyObject *StrokeAttribute_color_get(BPy_StrokeAttribute *self, void *UNUS
static int StrokeAttribute_color_set(BPy_StrokeAttribute *self, PyObject *value, void *UNUSED(closure))
{
- Vec3f *v = Vec3f_ptr_from_PyObject(value);
- if (!v) {
+ float v[3];
+ if (!float_array_from_PyObject(value, v, 3)) {
PyErr_SetString(PyExc_ValueError, "value must be a 3-dimensional vector");
return -1;
}
- self->sa->setColor(v->x(), v->y(), v->z());
- delete v;
+ self->sa->setColor(v[0], v[1], v[2]);
return 0;
}
@@ -551,12 +550,12 @@ static PyObject *StrokeAttribute_thickness_get(BPy_StrokeAttribute *self, void *
static int StrokeAttribute_thickness_set(BPy_StrokeAttribute *self, PyObject *value, void *UNUSED(closure))
{
- Vec2f *v = Vec2f_ptr_from_PyObject(value);
- if (!v) {
+ float v[2];
+ if (!float_array_from_PyObject(value, v, 2)) {
PyErr_SetString(PyExc_ValueError, "value must be a 2-dimensional vector");
return -1;
}
- self->sa->setThickness(v->x(), v->y());
+ self->sa->setThickness(v[0], v[1]);
return 0;
}
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
index 1279d1824fb..2215bd9df02 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
@@ -214,6 +214,13 @@ Smoother::Smoother(Stroke &ioStroke)
_safeTest = (_nbVertices > 4);
}
+Smoother::~Smoother()
+{
+ delete[] _vertex;
+ delete[] _curvature;
+ delete[] _normal;
+}
+
void Smoother::smooth(int nbIteration, real iFactorPoint, real ifactorCurvature, real iFactorCurvatureDifference,
real iAnisoPoint, real iAnisoNormal, real iAnisoCurvature, real iCarricatureFactor)
{
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
index bd2b28059d8..18472ff2c2a 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
@@ -154,7 +154,7 @@ class LIB_STROKE_EXPORT Smoother
public:
Smoother(Stroke &ioStroke);
- virtual ~Smoother() {}
+ virtual ~Smoother();
void smooth(int nbIterations, real iFactorPoint, real ifactorCurvature, real iFactorCurvatureDifference,
real iAnisoPoint, real iAnisoNormal, real iAnisoCurvature, real icarricatureFactor);