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:
authorCampbell Barton <ideasman42@gmail.com>2010-09-06 19:54:08 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-09-06 19:54:08 +0400
commit99954545ee23dbeb932add263e94e34ed85c91d5 (patch)
treeb142d81ff22b150f1f12ecf688e75e9da1b2fa01
parentf6c68f10196fd2e7a1831fdfdced6e39ce862e6d (diff)
bugfix [#23656] Problems retrieving properties from inside runtime-created PointerProperties
cant test if this fix solves the problem matt is having but it at least fixes an error caused by classes created in exec(), when the properties pointers were copied the hash key still referred to the python object which could be freed. in most cases this wouldnt happen (would be kept in bytecode) but with exec() the property string is freed immediately.
-rw-r--r--source/blender/makesrna/RNA_define.h2
-rw-r--r--source/blender/makesrna/intern/rna_define.c16
-rw-r--r--source/blender/python/intern/bpy_props.c20
3 files changed, 25 insertions, 13 deletions
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 6422950b5e4..16ca718e335 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -192,7 +192,7 @@ void RNA_def_struct_duplicate_pointers(StructRNA *srna);
void RNA_def_struct_free_pointers(StructRNA *srna);
void RNA_def_func_duplicate_pointers(FunctionRNA *func);
void RNA_def_func_free_pointers(FunctionRNA *func);
-void RNA_def_property_duplicate_pointers(PropertyRNA *prop);
+void RNA_def_property_duplicate_pointers(StructOrFunctionRNA *cont_, PropertyRNA *prop);
void RNA_def_property_free_pointers(PropertyRNA *prop);
int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier);
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 750b1eef2a9..1fed1663952 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -2617,14 +2617,26 @@ void RNA_def_func_free_pointers(FunctionRNA *func)
}
}
-void RNA_def_property_duplicate_pointers(PropertyRNA *prop)
+void RNA_def_property_duplicate_pointers(StructOrFunctionRNA *cont_, PropertyRNA *prop)
{
+ ContainerRNA *cont= cont_;
EnumPropertyItem *earray;
float *farray;
int *iarray;
int a;
- if(prop->identifier) prop->identifier= BLI_strdup(prop->identifier);
+ /* annoying since we just added this to a hash, could make this add the correct key to the hash in the first place */
+ if(prop->identifier) {
+ if(cont->prophash) {
+ BLI_ghash_remove(cont->prophash, (void*)prop->identifier, NULL, NULL);
+ prop->identifier= BLI_strdup(prop->identifier);
+ BLI_ghash_insert(cont->prophash, (void*)prop->identifier, prop);
+ }
+ else {
+ prop->identifier= BLI_strdup(prop->identifier);
+ }
+ }
+
if(prop->name) prop->name= BLI_strdup(prop->name);
if(prop->description) prop->description= BLI_strdup(prop->description);
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index 9ae7507a72a..12966819015 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -160,7 +160,7 @@ PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
- RNA_def_property_duplicate_pointers(prop);
+ RNA_def_property_duplicate_pointers(srna, prop);
Py_RETURN_NONE;
}
else { /* operators defer running this function */
@@ -236,7 +236,7 @@ PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
- RNA_def_property_duplicate_pointers(prop);
+ RNA_def_property_duplicate_pointers(srna, prop);
Py_RETURN_NONE;
}
else { /* operators defer running this function */
@@ -302,7 +302,7 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
- RNA_def_property_duplicate_pointers(prop);
+ RNA_def_property_duplicate_pointers(srna, prop);
Py_RETURN_NONE;
}
else { /* operators defer running this function */
@@ -379,7 +379,7 @@ PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
- RNA_def_property_duplicate_pointers(prop);
+ RNA_def_property_duplicate_pointers(srna, prop);
Py_RETURN_NONE;
}
else { /* operators defer running this function */
@@ -456,7 +456,7 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
- RNA_def_property_duplicate_pointers(prop);
+ RNA_def_property_duplicate_pointers(srna, prop);
Py_RETURN_NONE;
}
else { /* operators defer running this function */
@@ -533,7 +533,7 @@ PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
- RNA_def_property_duplicate_pointers(prop);
+ RNA_def_property_duplicate_pointers(srna, prop);
Py_RETURN_NONE;
}
else { /* operators defer running this function */
@@ -598,7 +598,7 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw)
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
- RNA_def_property_duplicate_pointers(prop);
+ RNA_def_property_duplicate_pointers(srna, prop);
Py_RETURN_NONE;
}
else { /* operators defer running this function */
@@ -704,7 +704,7 @@ PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
- RNA_def_property_duplicate_pointers(prop);
+ RNA_def_property_duplicate_pointers(srna, prop);
MEM_freeN(eitems);
Py_RETURN_NONE;
@@ -787,7 +787,7 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
- RNA_def_property_duplicate_pointers(prop);
+ RNA_def_property_duplicate_pointers(srna, prop);
Py_RETURN_NONE;
}
else { /* operators defer running this function */
@@ -847,7 +847,7 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
- RNA_def_property_duplicate_pointers(prop);
+ RNA_def_property_duplicate_pointers(srna, prop);
Py_RETURN_NONE;
}
else { /* operators defer running this function */