Commit: bc88ee329256d903308e67071c2edc2c8f32376d
Author: Campbell Barton
Date:   Fri Aug 11 19:09:03 2017 +1000
Branches: master
https://developer.blender.org/rBbc88ee329256d903308e67071c2edc2c8f32376d

Error in last commit, problems with unregister

We can't free the identifier before its used when
removing from the ghash.

===================================================================

M       source/blender/makesrna/intern/rna_define.c
M       source/blender/makesrna/intern/rna_nodetree.c
M       source/blender/makesrna/intern/rna_render.c
M       source/blender/makesrna/intern/rna_ui.c
M       source/blender/makesrna/intern/rna_userdef.c
M       source/blender/makesrna/intern/rna_wm.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_define.c 
b/source/blender/makesrna/intern/rna_define.c
index 5a1aec59362..0f8bc19bd6c 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -145,8 +145,25 @@ static void rna_brna_structs_add(BlenderRNA *brna, 
StructRNA *srna)
        if (srna->identifier[0] != '\0') {
                BLI_ghash_insert(brna->structs_map, (void *)srna->identifier, 
srna);
        }
+}
+
+#ifdef RNA_RUNTIME
+static void rna_brna_structs_remove_and_free(BlenderRNA *brna, StructRNA *srna)
+{
+       if (brna->structs_map) {
+               if (srna->identifier[0] != '\0') {
+                       BLI_ghash_remove(brna->structs_map, (void 
*)srna->identifier, NULL, NULL);
+               }
+       }
+
+       RNA_def_struct_free_pointers(srna);
 
+       if (srna->flag & STRUCT_RUNTIME) {
+               rna_freelinkN(&brna->structs, srna);
+       }
+       brna->structs_len -= 1;
 }
+#endif
 
 StructDefRNA *rna_find_struct_def(StructRNA *srna)
 {
@@ -655,10 +672,8 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
                        rna_freelinkN(&srna->functions, func);
        }
 
-       RNA_def_struct_free_pointers(srna);
 
-       if (srna->flag & STRUCT_RUNTIME)
-               rna_freelinkN(&brna->structs, srna);
+       rna_brna_structs_remove_and_free(brna, srna);
 #else
        UNUSED_VARS(brna, srna);
 #endif
diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index 05b64c959a4..00b881dabc7 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -595,11 +595,10 @@ static void rna_NodeTree_unregister(Main *UNUSED(bmain), 
StructRNA *type)
                return;
 
        RNA_struct_free_extension(type, &nt->ext);
+       RNA_struct_free(&BLENDER_RNA, type);
 
        ntreeTypeFreeLink(nt);
 
-       RNA_struct_free(&BLENDER_RNA, type);
-
        /* update while blender is running */
        WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
 }
@@ -1348,11 +1347,11 @@ static void rna_Node_unregister(Main *UNUSED(bmain), 
StructRNA *type)
                return;
 
        RNA_struct_free_extension(type, &nt->ext);
+       RNA_struct_free(&BLENDER_RNA, type);
 
        /* this also frees the allocated nt pointer, no MEM_free call needed! */
        nodeUnregisterType(nt);
 
-       RNA_struct_free(&BLENDER_RNA, type);
 
        /* update while blender is running */
        WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
@@ -1810,10 +1809,10 @@ static void rna_NodeSocket_unregister(Main 
*UNUSED(bmain), StructRNA *type)
                return;
        
        RNA_struct_free_extension(type, &st->ext_socket);
+       RNA_struct_free(&BLENDER_RNA, type);
 
        nodeUnregisterSocketType(st);
 
-       RNA_struct_free(&BLENDER_RNA, type);
 
        /* update while blender is running */
        WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
diff --git a/source/blender/makesrna/intern/rna_render.c 
b/source/blender/makesrna/intern/rna_render.c
index 44dcb72264a..c30765d8857 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -279,8 +279,8 @@ static void rna_RenderEngine_unregister(Main 
*UNUSED(bmain), StructRNA *type)
                return;
        
        RNA_struct_free_extension(type, &et->ext);
-       BLI_freelinkN(&R_engines, et);
        RNA_struct_free(&BLENDER_RNA, type);
+       BLI_freelinkN(&R_engines, et);
 }
 
 static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, 
void *data, const char *identifier,
diff --git a/source/blender/makesrna/intern/rna_ui.c 
b/source/blender/makesrna/intern/rna_ui.c
index 54b82fc89d6..64b41ac789f 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -177,9 +177,9 @@ static void rna_Panel_unregister(Main *UNUSED(bmain), 
StructRNA *type)
                return;
        
        RNA_struct_free_extension(type, &pt->ext);
+       RNA_struct_free(&BLENDER_RNA, type);
 
        BLI_freelinkN(&art->paneltypes, pt);
-       RNA_struct_free(&BLENDER_RNA, type);
 
        /* update while blender is running */
        WM_main_add_notifier(NC_WINDOW, NULL);
@@ -455,11 +455,10 @@ static void rna_UIList_unregister(Main *UNUSED(bmain), 
StructRNA *type)
                return;
 
        RNA_struct_free_extension(type, &ult->ext);
+       RNA_struct_free(&BLENDER_RNA, type);
 
        WM_uilisttype_freelink(ult);
 
-       RNA_struct_free(&BLENDER_RNA, type);
-
        /* update while blender is running */
        WM_main_add_notifier(NC_WINDOW, NULL);
 }
@@ -551,9 +550,9 @@ static void rna_Header_unregister(Main *UNUSED(bmain), 
StructRNA *type)
                return;
        
        RNA_struct_free_extension(type, &ht->ext);
+       RNA_struct_free(&BLENDER_RNA, type);
 
        BLI_freelinkN(&art->headertypes, ht);
-       RNA_struct_free(&BLENDER_RNA, type);
 
        /* update while blender is running */
        WM_main_add_notifier(NC_WINDOW, NULL);
@@ -673,11 +672,10 @@ static void rna_Menu_unregister(Main *UNUSED(bmain), 
StructRNA *type)
                return;
        
        RNA_struct_free_extension(type, &mt->ext);
+       RNA_struct_free(&BLENDER_RNA, type);
 
        WM_menutype_freelink(mt);
 
-       RNA_struct_free(&BLENDER_RNA, type);
-
        /* update while blender is running */
        WM_main_add_notifier(NC_WINDOW, NULL);
 }
diff --git a/source/blender/makesrna/intern/rna_userdef.c 
b/source/blender/makesrna/intern/rna_userdef.c
index 350cb02223f..19a25b4df11 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -606,9 +606,9 @@ static void rna_AddonPref_unregister(Main *UNUSED(bmain), 
StructRNA *type)
                return;
 
        RNA_struct_free_extension(type, &apt->ext);
+       RNA_struct_free(&BLENDER_RNA, type);
 
        BKE_addon_pref_type_remove(apt);
-       RNA_struct_free(&BLENDER_RNA, type);
 
        /* update while blender is running */
        WM_main_add_notifier(NC_WINDOW, NULL);
diff --git a/source/blender/makesrna/intern/rna_wm.c 
b/source/blender/makesrna/intern/rna_wm.c
index b5ecaf739c7..4aee03025f6 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -1269,10 +1269,11 @@ static void rna_Operator_unregister(struct Main *bmain, 
StructRNA *type)
 
        idname = ot->idname;
        WM_operatortype_remove_ptr(ot);
-       MEM_freeN((void *)idname);
 
        /* not to be confused with the RNA_struct_free that 
WM_operatortype_remove calls, they are 2 different srna's */
        RNA_struct_free(&BLENDER_RNA, type);
+
+       MEM_freeN((void *)idname);
 }
 
 static void **rna_Operator_instance(PointerRNA *ptr)

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to