- added RNA_struct_free_extension rather then having the funcs in each unregister func.

- use RNA_struct_blender_type_set to set the type to NULL before its freed

There is a memory error here when reloading scripts - ui_handler_panel_region, need to look into theis further.
This commit is contained in:
Campbell Barton
2009-08-16 07:26:29 +00:00
parent d86663ee1a
commit d776dcf795
5 changed files with 15 additions and 10 deletions

View File

@@ -1247,7 +1247,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
if(!pa || pa->paneltab!=NULL)
continue;
if(pa->type && pa->type->flag & PNL_NO_HEADER)
if(pa->type && pa->type->flag & PNL_NO_HEADER) // XXX - accessed freed panels when scripts reload, need to fix.
continue;
if(block->minx <= mx && block->maxx >= mx)

View File

@@ -63,6 +63,7 @@ void RNA_def_struct_path_func(StructRNA *srna, const char *path);
void RNA_def_struct_identifier(StructRNA *srna, const char *identifier);
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description);
void RNA_def_struct_ui_icon(StructRNA *srna, int icon);
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext);
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna);
/* Compact Property Definitions */

View File

@@ -458,6 +458,15 @@ void RNA_define_verify_sdna(int verify)
DefRNA.verify= verify;
}
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext)
{
#ifdef RNA_RUNTIME
ext->free(ext->data); /* decref's the PyObject that the srna owns */
RNA_struct_blender_type_set(srna, NULL); /* this gets accessed again - XXX fixme */
RNA_struct_py_type_set(srna, NULL); /* NULL the srna's value so RNA_struct_free wont complain of a leak */
#endif
}
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
{
#ifdef RNA_RUNTIME

View File

@@ -106,9 +106,7 @@ static void rna_RenderEngine_unregister(const bContext *C, StructRNA *type)
if(!et)
return;
et->ext.free(et->ext.data); /* decref's the PyObject that the srna owns */
RNA_struct_py_type_set(type, NULL); /* NULL the srna's value so RNA_struct_free wont complain of a leak */
RNA_struct_free_extension(type, &et->ext);
BLI_freelinkN(&R_engines, et);
RNA_struct_free(&BLENDER_RNA, type);
}

View File

@@ -138,8 +138,7 @@ static void rna_Panel_unregister(const bContext *C, StructRNA *type)
if(!(art=region_type_find(NULL, pt->space_type, pt->region_type)))
return;
pt->ext.free(pt->ext.data); /* decref's the PyObject that the srna owns */
RNA_struct_py_type_set(type, NULL); /* NULL the srna's value so RNA_struct_free wont complain of a leak */
RNA_struct_free_extension(type, &pt->ext);
BLI_freelinkN(&art->paneltypes, pt);
RNA_struct_free(&BLENDER_RNA, type);
@@ -236,8 +235,7 @@ static void rna_Header_unregister(const bContext *C, StructRNA *type)
if(!(art=region_type_find(NULL, ht->space_type, RGN_TYPE_HEADER)))
return;
ht->ext.free(ht->ext.data); /* decref's the PyObject that the srna owns */
RNA_struct_py_type_set(type, NULL); /* NULL the srna's value so RNA_struct_free wont complain of a leak */
RNA_struct_free_extension(type, &ht->ext);
BLI_freelinkN(&art->headertypes, ht);
RNA_struct_free(&BLENDER_RNA, type);
@@ -353,8 +351,7 @@ static void rna_Menu_unregister(const bContext *C, StructRNA *type)
if(!(art=region_type_find(NULL, mt->space_type, RGN_TYPE_HEADER)))
return;
mt->ext.free(mt->ext.data); /* decref's the PyObject that the srna owns */
RNA_struct_py_type_set(type, NULL); /* NULL the srna's value so RNA_struct_free wont complain of a leak */
RNA_struct_free_extension(type, &mt->ext);
BLI_freelinkN(&art->menutypes, mt);
RNA_struct_free(&BLENDER_RNA, type);