[Bf-blender-cvs] [ec25084f5a4] master: Fix T77541: Unregistering DATA_PT_modifiers doesn't remove modifier panels

Hans Goudey noreply at git.blender.org
Mon Jun 15 15:07:00 CEST 2020


Commit: ec25084f5a404cbca4ceffd659d46b21c758522a
Author: Hans Goudey
Date:   Mon Jun 15 09:06:54 2020 -0400
Branches: master
https://developer.blender.org/rBec25084f5a404cbca4ceffd659d46b21c758522a

Fix T77541: Unregistering DATA_PT_modifiers doesn't remove modifier panels

This is a pretty quick fix; the solution is just removing all the
instanced panels whena panel is unregistered. This also necessitates
adding the option to call UI_panels_free_instanced with NULL context.

Differential Revision: https://developer.blender.org/D7977

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

M	source/blender/editors/interface/interface_panel.c
M	source/blender/makesrna/intern/rna_ui.c

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

diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 5f56a93c5eb..2b8e7cdb2e7 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -354,13 +354,19 @@ static void panel_delete(ARegion *region, ListBase *panels, Panel *panel)
   MEM_freeN(panel);
 }
 
+/**
+ * Remove instanced panels from the region's panel list.
+ *
+ * \note Can be called with NULL \a C, but it should be avoided because
+ * handlers might not be removed.
+ */
 void UI_panels_free_instanced(bContext *C, ARegion *region)
 {
   /* Delete panels with the instanced flag. */
   LISTBASE_FOREACH_MUTABLE (Panel *, panel, &region->panels) {
     if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) {
       /* Make sure the panel's handler is removed before deleting it. */
-      if (panel->activedata != NULL) {
+      if (C != NULL && panel->activedata != NULL) {
         panel_activate_state(C, panel, PANEL_STATE_EXIT);
       }
       panel_delete(region, &region->panels, panel);
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 9c9d10afa63..5228f00d0de 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -227,6 +227,9 @@ static void rna_Panel_unregister(Main *bmain, StructRNA *type)
                 }
               }
             }
+            /* The unregistered panel might have had a template that added instanced panels,
+             * so remove them just in case. They can be re-added on redraw anyway. */
+            UI_panels_free_instanced(NULL, region);
           }
         }
       }



More information about the Bf-blender-cvs mailing list