Fix leak in UI Panels
[blender.git] / source / blender / blenkernel / intern / screen.c
index 4125a35cb3373d3652c8f9b94ae5f4ce4e493ba2..7401ef28f62808afcc3d70bda624304be61daf63 100644 (file)
@@ -308,7 +308,16 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
                ar->v2d.tab_offset = NULL;
        }
 
-       BLI_freelistN(&ar->panels);
+       if (!BLI_listbase_is_empty(&ar->panels)) {
+               Panel *pa, *pa_next;
+               for (pa = ar->panels.first; pa; pa = pa_next) {
+                       pa_next = pa->next;
+                       if (pa->activedata) {
+                               MEM_freeN(pa->activedata);
+                       }
+                       MEM_freeN(pa);
+               }
+       }
 
        for (uilst = ar->ui_lists.first; uilst; uilst = uilst->next) {
                if (uilst->dyn_data) {