[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26999] trunk/blender/source/blender/ python/intern/bpy_props.c: mostly fixed [#21172] Reloading scripts leaks memory (F8)

Martin Poirier theeth at yahoo.com
Thu Feb 18 04:56:16 CET 2010


The patch did both registration and unregistration through the list built with the meta class.

For dependencies check, it's a tad more complex then that (considering they can be runtime deps). This could be done in the per module register though.

Martin

--- On Wed, 2/17/10, Campbell Barton <ideasman42 at gmail.com> wrote:

> From: Campbell Barton <ideasman42 at gmail.com>
> Subject: Re: [Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26999] trunk/blender/source/blender/ python/intern/bpy_props.c: mostly fixed [#21172] Reloading scripts leaks memory (F8)
> To: "bf-blender developers" <bf-committers at blender.org>
> Received: Wednesday, February 17, 2010, 5:30 PM
> Yep, it probably should unregister
> them the same way, need to spend
> some more time on this since it could have some bad side
> effects if
> parts of the registered class are still in use.
> 
> On Wed, Feb 17, 2010 at 11:22 PM, Martin Poirier <theeth at yahoo.com>
> wrote:
> > Can't it unregister them the same way the rest (UI
> elements, operators, ...) is unregistered?
> >
> > Not to belabor my point, but registering with the
> metaclass like my patch does simplifies that problems a
> lot.
> >
> > Even if you want to do it manually, you can still use
> the list built by the metaclass to check if some types are
> not unregistered properly.
> >
> > Martin
> >
> > --- On Wed, 2/17/10, Campbell Barton <ideasman42 at gmail.com>
> wrote:
> >
> >> From: Campbell Barton <ideasman42 at gmail.com>
> >> Subject: [Bf-blender-cvs] SVN commit:
> /data/svn/bf-blender [26999] trunk/blender/source/blender/
> python/intern/bpy_props.c: mostly fixed [#21172] Reloading
> scripts leaks memory (F8)
> >> To: bf-blender-cvs at blender.org
> >> Received: Wednesday, February 17, 2010, 4:58 PM
> >> Revision: 26999
> >>           http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26999
> >> Author:   campbellbarton
> >> Date:     2010-02-17 22:58:08 +0100
> >> (Wed, 17 Feb 2010)
> >>
> >> Log Message:
> >> -----------
> >> mostly fixed [#21172] Reloading scripts leaks
> memory (F8)
> >> the same properties were being registered many
> times with
> >> built in structs.
> >>
> >> blender memory at least is not leaking, but it
> seems python
> >> is still not freeing some memory.
> >>
> >> For the moment dont allow existing properties to
> be
> >> registered again, will need to have a way to
> unregister rna
> >> properties.
> >>
> >> Modified Paths:
> >> --------------
> >>
> >>
> trunk/blender/source/blender/python/intern/bpy_props.c
> >>
> >> Modified:
> >>
> trunk/blender/source/blender/python/intern/bpy_props.c
> >>
> ===================================================================
> >> ---
> >>
> trunk/blender/source/blender/python/intern/bpy_props.c
> >> 2010-02-17 19:50:42 UTC (rev 26998)
> >> +++
> >>
> trunk/blender/source/blender/python/intern/bpy_props.c
> >> 2010-02-17 21:58:08 UTC (rev 26999)
> >> @@ -87,6 +87,14 @@
> >>      return ret;
> >>  }
> >>
> >> +static int bpy_struct_id_used(StructRNA *srna,
> char
> >> *identifier)
> >> +{
> >> +    PointerRNA ptr;
> >> +    RNA_pointer_create(NULL, srna, NULL,
> >> &ptr);
> >> +    return
> >> (RNA_struct_find_property(&ptr, identifier) !=
> NULL);
> >> +}
> >> +
> >> +
> >>  /* Function that sets RNA, NOTE - self is NULL
> when called
> >> from python, but being abused from C so we can
> pass the srna
> >> allong
> >>   * This isnt incorrect since its a python object
> -
> >> but be careful */
> >>  static char BPy_BoolProperty_doc[] =
> >> @@ -125,11 +133,17 @@
> >>          if
> >> (!PyArg_ParseTupleAndKeywords(args, kw,
> >> "s|ssiO!s:BoolProperty", (char **)kwlist,
> &id,
> >> &name, &description, &def,
> &PySet_Type,
> >> &pyopts, &pysubtype))
> >>
> >> return NULL;
> >>
> >> +
> >> if(bpy_struct_id_used(srna, id)) {
> >> +
> >> // PyErr_Format(PyExc_TypeError, "BoolProperty():
> '%s'
> >> already defined.", id);
> >> +
> >> // return NULL;
> >> +
> >> Py_RETURN_NONE;
> >> +        }
> >> +
> >>          if(pyopts &&
> >> pyrna_set_to_enum_bitfield(property_flag_items,
> pyopts,
> >> &opts, "BoolProperty(options={...}):"))
> >>
> >> return NULL;
> >>
> >>          if(pysubtype
> >> &&
> >>
> RNA_enum_value_from_id(property_subtype_number_items,
> >> pysubtype, &subtype)==0) {
> >> -
> >> PyErr_Format(PyExc_TypeError,
> "BoolProperty(subtype='%s'):
> >> invalid subtype.");
> >> +
> >> PyErr_Format(PyExc_TypeError,
> "BoolProperty(subtype='%s'):
> >> invalid subtype.", pysubtype);
> >>
> >> return NULL;
> >>          }
> >>
> >> @@ -187,11 +201,17 @@
> >>          if
> >> (!PyArg_ParseTupleAndKeywords(args, kw,
> >> "s|ssOO!si:BoolVectorProperty", (char **)kwlist,
> &id,
> >> &name, &description, &pydef,
> &PySet_Type,
> >> &pyopts, &pysubtype, &size))
> >>
> >> return NULL;
> >>
> >> +
> >> if(bpy_struct_id_used(srna, id)) {
> >> +
> >> // PyErr_Format(PyExc_TypeError,
> "BoolVectorProperty(): '%s'
> >> already defined.", id);
> >> +
> >> // return NULL;
> >> +
> >> Py_RETURN_NONE;
> >> +        }
> >> +
> >>          if(pyopts &&
> >> pyrna_set_to_enum_bitfield(property_flag_items,
> pyopts,
> >> &opts, "BoolVectorProperty(options={...}):"))
> >>
> >> return NULL;
> >>
> >>          if(pysubtype
> >> &&
> >>
> RNA_enum_value_from_id(property_subtype_array_items,
> >> pysubtype, &subtype)==0) {
> >> -
> >> PyErr_Format(PyExc_TypeError,
> >> "BoolVectorProperty(subtype='%s'): invalid
> subtype.");
> >> +
> >> PyErr_Format(PyExc_TypeError,
> >> "BoolVectorProperty(subtype='%s'): invalid
> subtype.",
> >> pysubtype);
> >>
> >> return NULL;
> >>          }
> >>
> >> @@ -256,11 +276,17 @@
> >>          if
> >> (!PyArg_ParseTupleAndKeywords(args, kw,
> >> "s|ssiiiiiiO!s:IntProperty", (char **)kwlist,
> &id,
> >> &name, &description, &def, &min,
> &max,
> >> &soft_min, &soft_max, &step,
> &PySet_Type,
> >> &pyopts, &pysubtype))
> >>
> >> return NULL;
> >>
> >> +
> >> if(bpy_struct_id_used(srna, id)) {
> >> +
> >> // PyErr_Format(PyExc_TypeError, "IntProperty():
> '%s'
> >> already defined.", id);
> >> +
> >> // return NULL;
> >> +
> >> Py_RETURN_NONE;
> >> +        }
> >> +
> >>          if(pyopts &&
> >> pyrna_set_to_enum_bitfield(property_flag_items,
> pyopts,
> >> &opts, "IntProperty(options={...}):"))
> >>
> >> return NULL;
> >>
> >>          if(pysubtype
> >> &&
> >>
> RNA_enum_value_from_id(property_subtype_number_items,
> >> pysubtype, &subtype)==0) {
> >> -
> >> PyErr_Format(PyExc_TypeError,
> "IntProperty(subtype='%s'):
> >> invalid subtype.");
> >> +
> >> PyErr_Format(PyExc_TypeError,
> "IntProperty(subtype='%s'):
> >> invalid subtype.", pysubtype);
> >>
> >> return NULL;
> >>          }
> >>
> >> @@ -319,11 +345,17 @@
> >>          if
> >> (!PyArg_ParseTupleAndKeywords(args, kw,
> >> "s|ssOiiiiO!si:IntVectorProperty", (char
> **)kwlist, &id,
> >> &name, &description, &pydef, &min,
> &max,
> >> &soft_min, &soft_max, &PySet_Type,
> &pyopts,
> >> &pysubtype, &size))
> >>
> >> return NULL;
> >>
> >> +
> >> if(bpy_struct_id_used(srna, id)) {
> >> +
> >> // PyErr_Format(PyExc_TypeError,
> "IntVectorProperty(): '%s'
> >> already defined.", id);
> >> +
> >> // return NULL;
> >> +
> >> Py_RETURN_NONE;
> >> +        }
> >> +
> >>          if(pyopts &&
> >> pyrna_set_to_enum_bitfield(property_flag_items,
> pyopts,
> >> &opts, "IntVectorProperty(options={...}):"))
> >>
> >> return NULL;
> >>
> >>          if(pysubtype
> >> &&
> >>
> RNA_enum_value_from_id(property_subtype_array_items,
> >> pysubtype, &subtype)==0) {
> >> -
> >> PyErr_Format(PyExc_TypeError,
> >> "IntVectorProperty(subtype='%s'): invalid
> subtype.");
> >> +
> >> PyErr_Format(PyExc_TypeError,
> >> "IntVectorProperty(subtype='%s'): invalid
> subtype.",
> >> pysubtype);
> >>
> >> return NULL;
> >>          }
> >>
> >> @@ -395,11 +427,17 @@
> >>          if
> >> (!PyArg_ParseTupleAndKeywords(args, kw,
> >> "s|ssffffffiO!ss:FloatProperty", (char **)kwlist,
> &id,
> >> &name, &description, &def, &min,
> &max,
> >> &soft_min, &soft_max, &step,
> &precision,
> >> &PySet_Type, &pyopts, &pysubtype,
> &pyunit))
> >>
> >> return NULL;
> >>
> >> +
> >> if(bpy_struct_id_used(srna, id)) {
> >> +
> >> // PyErr_Format(PyExc_TypeError, "FloatProperty():
> '%s'
> >> already defined.", id);
> >> +
> >> // return NULL;
> >> +
> >> Py_RETURN_NONE;
> >> +        }
> >> +
> >>          if(pyopts &&
> >> pyrna_set_to_enum_bitfield(property_flag_items,
> pyopts,
> >> &opts, "FloatProperty(options={...}):"))
> >>

> >> return NULL;
> >>
> >>          if(pysubtype
> >> &&
> >>
> RNA_enum_value_from_id(property_subtype_number_items,
> >> pysubtype, &subtype)==0) {
> >> -
> >> PyErr_Format(PyExc_TypeError,
> "FloatProperty(subtype='%s'):
> >> invalid subtype.");
> >> +
> >> PyErr_Format(PyExc_TypeError,
> "FloatProperty(subtype='%s'):
> >> invalid subtype.", pysubtype);
> >>
> >> return NULL;
> >>          }
> >>
> >> @@ -463,11 +501,17 @@
> >>          if
> >> (!PyArg_ParseTupleAndKeywords(args, kw,
> >> "s|ssOfffffiO!si:FloatVectorProperty", (char
> **)kwlist,
> >> &id, &name, &description, &pydef,
> &min,
> >> &max, &soft_min, &soft_max,
> &step,
> >> &precision, &PySet_Type, &pyopts,
> >> &pysubtype, &size))
> >>
> >> return NULL;
> >>
> >> +
> >> if(bpy_struct_id_used(srna, id)) {
> >> +
> >> // PyErr_Format(PyExc_TypeError,
> "FloatVectorProperty():
> >> '%s' already defined.", id);
> >> +
> >> // return NULL;
> >> +
> >> Py_RETURN_NONE;
> >> +        }
> >> +
> >>          if(pyopts &&
> >> pyrna_set_to_enum_bitfield(property_flag_items,
> pyopts,
> >> &opts,
> "FloatVectorProperty(options={...}):"))
> >>
> >> return NULL;
> >>
> >>          if(pysubtype
> >> &&
> >>
> RNA_enum_value_from_id(property_subtype_array_items,
> >> pysubtype, &subtype)==0) {
> >> -
> >> PyErr_Format(PyExc_TypeError,
> >> "FloatVectorProperty(subtype='%s'): invalid
> subtype.");
> >> +
> >> PyErr_Format(PyExc_TypeError,
> >> "FloatVectorProperty(subtype='%s'): invalid
> subtype.",
> >> pysubtype);
> >>
> >> return NULL;
> >>          }
> >>
> >> @@ -533,11 +577,17 @@
> >>          if
> >> (!PyArg_ParseTupleAndKeywords(args, kw,
> >> "s|sssiO!s:StringProperty", (char **)kwlist,
> &id,
> >> &name, &description, &def,
> &maxlen,
> >> &PySet_Type, &pyopts, &pysubtype))
> >>
> >> return NULL;
> >>
> >> +
> >> if(bpy_struct_id_used(srna, id)) {
> >> +
> >> // PyErr_Format(PyExc_TypeError,
> "StringProperty(): '%s'
> >> already defined.", id);
> >> +
> >> // return NULL;
> >> +
> >> Py_RETURN_NONE;
> >> +        }
> >> +
> >>          if(pyopts &&
> >> pyrna_set_to_enum_bitfield(property_flag_items,
> pyopts,
> >> &opts, "StringProperty(options={...}):"))
> >>
> >> return NULL;
> >>
> >>          if(pysubtype
> >> &&
> >>
> RNA_enum_value_from_id(property_subtype_string_items,
> >> pysubtype, &subtype)==0) {
> >> -
> >> PyErr_Format(PyExc_TypeError,
> "StringProperty(subtype='%s'):
> >> invalid subtype.");
> >> +
> >> PyErr_Format(PyExc_TypeError,
> "StringProperty(subtype='%s'):
> >> invalid subtype.", pysubtype);
> >>
> >> return NULL;
> >>          }
> >>
> >> @@ -639,6 +689,12 @@
> >>          if
> >> (!PyArg_ParseTupleAndKeywords(args, kw,
> >> "sO|sssO!:EnumProperty", (char **)kwlist,
> &id,
> >> &items, &name, &description,
> &def,
> >> &PySet_Type, &pyopts))
> >>
> >> return NULL;
> >>
> >> +
> >> if(bpy_struct_id_used(srna, id)) {
> >> +
> >> // PyErr_Format(PyExc_TypeError, "EnumProperty():
> '%s'
> >> already defined.", id);
> >> +
> >> // return NULL;
> >> +
> >> Py_RETURN_NONE;
> >> +        }
> >> +
> >>          if(pyopts &&
> >> pyrna_set_to_enum_bitfield(property_flag_items,
> pyopts,
> >> &opts, "EnumProperty(options={...}):"))
> >>
> >> return NULL;
> >>
> >> @@ -713,6 +769,12 @@
> >>          if
> >> (!PyArg_ParseTupleAndKeywords(args, kw,
> >> "sO|ssO!:PointerProperty", (char **)kwlist,
> &id,
> >> &type, &name, &description,
> &PySet_Type,
> >> &pyopts))
> >>
> >> return NULL;
> >>
> >> +
> >> if(bpy_struct_id_used(srna, id)) {
> >> +
> >> // PyErr_Format(PyExc_TypeError,
> "PointerProperty(): '%s'
> >> already defined.", id);
> >> +
> >> // return NULL;
> >> +
> >> Py_RETURN_NONE;
> >> +        }
> >> +
> >>          if(pyopts &&
> >> pyrna_set_to_enum_bitfield(property_flag_items,
> pyopts,
> >> &opts, "PointerProperty(options={...}):"))
> >>
> >> return NULL;
> >>
> >> @@ -768,6 +830,12 @@
> >>          if
> >> (!PyArg_ParseTupleAndKeywords(args, kw,
> >> "sO|ssO!:CollectionProperty", (char **)kwlist,
> &id,
> >> &type, &name, &description,
> &PySet_Type,
> >> &pyopts))
> >>
> >> return NULL;
> >>
> >> +
> >> if(bpy_struct_id_used(srna, id)) {
> >> +
> >> // PyErr_Format(PyExc_TypeError,
> "CollectionProperty(): '%s'
> >> already defined.", id);
> >> +
> >> // return NULL;
> >> +
> >> Py_RETURN_NONE;
> >> +        }
> >> +
> >>          if(pyopts &&
> >> pyrna_set_to_enum_bitfield(property_flag_items,
> pyopts,
> >> &opts, "CollectionProperty(options={...}):"))
> >>
> >> return NULL;
> >>
> >>
> >>
> >> _______________________________________________
> >> Bf-blender-cvs mailing list
> >> Bf-blender-cvs at blender.org
> >> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
> >>
> >
> >
> >    
>  __________________________________________________________________
> > Yahoo! Canada Toolbar: Search from anywhere on the
> web, and bookmark your favourite sites. Download it now
> > http://ca.toolbar.yahoo.com.
> > _______________________________________________
> > Bf-committers mailing list
> > Bf-committers at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-committers
> >
> 
> 
> 
> -- 
> - Campbell
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
> 


      __________________________________________________________________
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now
http://ca.toolbar.yahoo.com.


More information about the Bf-committers mailing list