[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21779] branches/soc-2008-mxcurioni/source /blender/freestyle/intern/python/Iterator: Fixed a refcount bug concerning ChainPredicateIterator.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Tue Jul 21 21:44:15 CEST 2009


Revision: 21779
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21779
Author:   kjym3
Date:     2009-07-21 21:44:15 +0200 (Tue, 21 Jul 2009)

Log Message:
-----------
Fixed a refcount bug concerning ChainPredicateIterator.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp	2009-07-21 19:08:36 UTC (rev 21778)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp	2009-07-21 19:44:15 UTC (rev 21779)
@@ -13,6 +13,7 @@
 
 /*---------------  Python API function prototypes for ChainPredicateIterator instance  -----------*/
 static int ChainPredicateIterator___init__(BPy_ChainPredicateIterator *self, PyObject *args);
+static void ChainPredicateIterator___dealloc__(BPy_ChainPredicateIterator *self);
 
 /*----------------------ChainPredicateIterator instance definitions ----------------------------*/
 static PyMethodDef BPy_ChainPredicateIterator_methods[] = {
@@ -30,7 +31,7 @@
 	0,							/* tp_itemsize */
 	
 	/* methods */
-	NULL,	/* tp_dealloc */
+	(destructor)ChainPredicateIterator___dealloc__,	/* tp_dealloc */
 	NULL,                       				/* printfunc tp_print; */
 	NULL,                       				/* getattrfunc tp_getattr; */
 	NULL,                       				/* setattrfunc tp_setattr; */
@@ -116,6 +117,8 @@
 
 	if( obj1 && BPy_ChainPredicateIterator_Check(obj1)  ) { 
 		self->cp_it = new ChainPredicateIterator(*( ((BPy_ChainPredicateIterator *) obj1)->cp_it ));
+		self->upred = NULL;
+		self->bpred = NULL;
 	
 	} else if( 	obj1 && BPy_UnaryPredicate1D_Check(obj1) &&
 	  			obj2 && BPy_BinaryPredicate1D_Check(obj2) ) {
@@ -144,6 +147,10 @@
 		bool orientation = ( obj6 ) ? bool_from_PyBool(obj6) : true;
 	
 		self->cp_it = new ChainPredicateIterator( *up1D, *bp1D, restrictToSelection, restrictToUnvisited, begin, orientation);
+		self->upred = obj1;
+		self->bpred = obj2;
+		Py_INCREF( self->upred );
+		Py_INCREF( self->bpred );
 	
 	} else {
 		bool restrictToSelection = ( obj1 ) ? bool_from_PyBool(obj1) : true;
@@ -160,6 +167,8 @@
 		bool orientation = ( obj4 ) ? bool_from_PyBool(obj4) : true;
 		
 		self->cp_it = new ChainPredicateIterator( restrictToSelection, restrictToUnvisited, begin, orientation);	
+		self->upred = NULL;
+		self->bpred = NULL;
 	}
 	
 	self->py_c_it.c_it = self->cp_it;
@@ -171,6 +180,12 @@
 	
 }
 
+void ChainPredicateIterator___dealloc__(BPy_ChainPredicateIterator *self)
+{
+	Py_XDECREF( self->upred );
+	Py_XDECREF( self->bpred );
+	ChainingIterator_Type.tp_dealloc((PyObject *)self);
+}
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h	2009-07-21 19:08:36 UTC (rev 21778)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h	2009-07-21 19:44:15 UTC (rev 21779)
@@ -22,6 +22,8 @@
 typedef struct {
 	BPy_ChainingIterator py_c_it;
 	ChainPredicateIterator *cp_it;
+	PyObject *upred;
+	PyObject *bpred;
 } BPy_ChainPredicateIterator;
 
 ///////////////////////////////////////////////////////////////////////////////////////////





More information about the Bf-blender-cvs mailing list