Fix T65999: Crash when disabling an addon while its panel is visible
Note, the performance of the tests we run here is still bad since we have plenty of panels around. But better than the crash. Reviewers: brecht Differential Revision: https://developer.blender.org/D5116
This commit is contained in:
parent
367cd72b23
commit
a6d2f9ffd0
Notes:
blender-bot
2024-04-11 14:26:06 +02:00
Referenced by issue #65999, Crash when disabling an addon while its panel is visible in the viewport
|
@ -180,7 +180,7 @@ static void panel_draw_header_preset(const bContext *C, Panel *pnl)
|
|||
RNA_parameter_list_free(&list);
|
||||
}
|
||||
|
||||
static void rna_Panel_unregister(Main *UNUSED(bmain), StructRNA *type)
|
||||
static void rna_Panel_unregister(Main *bmain, StructRNA *type)
|
||||
{
|
||||
ARegionType *art;
|
||||
PanelType *pt = RNA_struct_blender_type_get(type);
|
||||
|
@ -210,6 +210,23 @@ static void rna_Panel_unregister(Main *UNUSED(bmain), StructRNA *type)
|
|||
BLI_freelistN(&pt->children);
|
||||
BLI_freelinkN(&art->paneltypes, pt);
|
||||
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
|
||||
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
|
||||
for (ARegion *region = regionbase->first; region; region = region->next) {
|
||||
if (region->type == art) {
|
||||
for (Panel *pa = region->panels.first; pa; pa = pa->next) {
|
||||
if (pa->type == pt) {
|
||||
pa->type = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* update while blender is running */
|
||||
WM_main_add_notifier(NC_WINDOW, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue