From 760e79d8092a121b9d0e1cd02019478c808acae9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Jun 2018 17:26:38 +0200 Subject: WM: rename BKE_regiontype_from_id This returns the first as a fallback, causing confusing usage. Renamed and added a version of the function that doesn't. --- source/blender/blenkernel/intern/screen.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/screen.c') diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 2b1cf0a01df..6723e826cdb 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -107,7 +107,7 @@ SpaceType *BKE_spacetype_from_id(int spaceid) return NULL; } -ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid) +ARegionType *BKE_regiontype_from_id_or_first(SpaceType *st, int regionid) { ARegionType *art; @@ -119,6 +119,18 @@ ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid) return st->regiontypes.first; } +ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid) +{ + ARegionType *art; + + for (art = st->regiontypes.first; art; art = art->next) { + if (art->regionid == regionid) { + return art; + } + } + return NULL; +} + const ListBase *BKE_spacetypes_list(void) { @@ -185,7 +197,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar) /* use optional regiondata callback */ if (ar->regiondata) { - ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype); + ARegionType *art = BKE_regiontype_from_id_or_first(st, ar->regiontype); if (art && art->duplicate) newar->regiondata = art->duplicate(ar->regiondata); @@ -295,7 +307,7 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar) uiList *uilst; if (st) { - ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype); + ARegionType *art = BKE_regiontype_from_id_or_first(st, ar->regiontype); if (art && art->free) art->free(ar); -- cgit v1.2.3