Cleanup: Add/use utility to remove regions

This commit is contained in:
Julian Eisel 2019-09-20 12:26:06 +02:00
parent 09b728ff3e
commit f5dc979a7e
4 changed files with 14 additions and 9 deletions

View File

@ -66,6 +66,7 @@ void ED_region_do_listen(struct wmWindow *win,
void ED_region_do_layout(struct bContext *C, struct ARegion *ar);
void ED_region_do_draw(struct bContext *C, struct ARegion *ar);
void ED_region_exit(struct bContext *C, struct ARegion *ar);
void ED_region_remove(struct bContext *C, struct ScrArea *sa, struct ARegion *ar);
void ED_region_pixelspace(struct ARegion *ar);
void ED_region_update_rect(struct ARegion *ar);
void ED_region_init(struct ARegion *ar);

View File

@ -519,6 +519,17 @@ void ED_screen_ensure_updated(wmWindowManager *wm, wmWindow *win, bScreen *scree
}
}
/**
* Utility to exit and free an area-region. Screen level regions (menus/popups) need to be treated
* slightly differently, see #ui_region_temp_remove().
*/
void ED_region_remove(bContext *C, ScrArea *sa, ARegion *ar)
{
ED_region_exit(C, ar);
BKE_area_region_free(sa->type, ar);
BLI_freelinkN(&sa->regionbase, ar);
}
/* *********** exit calls are for closing running stuff ******** */
void ED_region_exit(bContext *C, ARegion *ar)

View File

@ -3848,10 +3848,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
for (ar = sa->regionbase.first; ar; ar = arn) {
arn = ar->next;
if (ar->alignment == RGN_ALIGN_QSPLIT) {
ED_region_exit(C, ar);
BKE_area_region_free(sa->type, ar);
BLI_remlink(&sa->regionbase, ar);
MEM_freeN(ar);
ED_region_remove(C, sa, ar);
}
}
ED_area_tag_redraw(sa);

View File

@ -307,11 +307,7 @@ static void file_refresh(const bContext *C, ScrArea *sa)
}
/* If there's _no_ file-operation, ensure we _don't_ have the option region */
else if (sa && (sfile->op == NULL) && (region_tool_props != NULL)) {
/* Remove TOOL_PROPS region. */
ED_region_exit((bContext *)C, region_tool_props);
BKE_area_region_free(sa->type, region_tool_props);
BLI_remlink(&sa->regionbase, region_tool_props);
MEM_freeN(region_tool_props);
ED_region_remove(C, sa, region_tool_props);
}
ED_area_tag_redraw(sa);