From df57ea7f3b9d750ab322692bf50828bd4c10371c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Jun 2019 16:01:19 +1000 Subject: Fix panel-type re-registration with parents The order of panel types changes when re-registering existing types. Fixes an error exposed by T65393. --- source/blender/makesrna/intern/rna_ui.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source/blender/makesrna/intern/rna_ui.c') diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 82315605ee5..1e5f1dc20ec 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -279,12 +279,24 @@ static StructRNA *rna_Panel_register(Main *bmain, /* check if we have registered this panel type before, and remove it */ for (pt = art->paneltypes.first; pt; pt = pt->next) { if (STREQ(pt->idname, dummypt.idname)) { + PanelType *pt_next = pt->next; if (pt->ext.srna) { rna_Panel_unregister(bmain, pt->ext.srna); } else { BLI_freelinkN(&art->paneltypes, pt); } + + /* The order of panel types will be altered on re-registration. */ + if (dummypt.parent_id[0] && (parent == NULL)) { + for (pt = pt_next; pt; pt = pt->next) { + if (STREQ(pt->idname, dummypt.parent_id)) { + parent = pt; + break; + } + } + } + break; } @@ -292,6 +304,7 @@ static StructRNA *rna_Panel_register(Main *bmain, parent = pt; } } + if (!RNA_struct_available_or_report(reports, dummypt.idname)) { return NULL; } -- cgit v1.2.3