diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-08-16 11:26:29 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-08-16 11:26:29 +0400 |
commit | d776dcf795c838996af16fca27922cec61d84b28 (patch) | |
tree | 09d3c99d48353a6ba53858505d1d4259f8d905c7 | |
parent | d86663ee1a4e845afd15752bac6dfb05dd675f69 (diff) |
- 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.
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_define.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 9 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_render.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui.c | 9 |
5 files changed, 15 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 846fbe75072..efff5b8f39c 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -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) diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index ae9eaba8646..33f5d7137b8 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -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 */ diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index ffbacdee69f..0861d7d51a0 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -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 diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 040284cb07b..eaea62d36ae 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -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); } diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 5a33bcd6374..660dbb49027 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -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); |