diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-11 03:17:43 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-11 03:17:43 +0400 |
commit | 45f336c3a10e17227a3a7a4cb599c019d9e761d2 (patch) | |
tree | ebe8e11bf2b5058e8e67e94a046895d43c8e55fe /source | |
parent | 6238fb4c43682f37172ddbb5a6bdac3dcd2a3aa6 (diff) |
UI: correct own bad use of bool and document area_copy_data args
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/screen/area.c | 44 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 4 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_intern.h | 2 |
3 files changed, 27 insertions, 23 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 71c55ddc4d5..32e4301d492 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1374,9 +1374,16 @@ void ED_region_toggle_hidden(bContext *C, ARegion *ar) region_toggle_hidden(C, ar, 1); } -/* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */ -/* area vertices were set */ -void area_copy_data(ScrArea *sa1, ScrArea *sa2, const bool swap_space) +/** + * sa2 to sa1, + * we swap spaces for fullscreen to keep all allocated data area vertices were set + * + * \param swap_space + * - 0: overwrite \a sa1 (freeing its data). + * - 1: simply swap. + * - 2: overwrite \a sa1 (when sa1 is calloc'd memory). + */ +void area_copy_data(ScrArea *sa1, ScrArea *sa2, const char swap_space) { SpaceType *st; ARegion *ar; @@ -1387,34 +1394,31 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, const bool swap_space) sa1->type = sa2->type; sa1->butspacetype = sa2->butspacetype; - if (swap_space == 1) { + if (swap_space == 0) { + BKE_spacedata_freelist(&sa1->spacedata); + BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata); + } + else if (swap_space == 1) { SWAP(ListBase, sa1->spacedata, sa2->spacedata); - /* exception: ensure preview is reset */ -// if (sa1->spacetype == SPACE_VIEW3D) -// XXX BIF_view3d_previewrender_free(sa1->spacedata.first); } else if (swap_space == 2) { BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata); } - else { - BKE_spacedata_freelist(&sa1->spacedata); - BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata); - } /* Note; SPACE_EMPTY is possible on new screens */ /* regions */ - if (swap_space == 1) { + if (swap_space == 0) { + st = BKE_spacetype_from_id(spacetype); + for (ar = sa1->regionbase.first; ar; ar = ar->next) + BKE_area_region_free(st, ar); + BLI_freelistN(&sa1->regionbase); + } + else if (swap_space == 1) { SWAP(ListBase, sa1->regionbase, sa2->regionbase); } - else { - if (swap_space < 2) { - st = BKE_spacetype_from_id(spacetype); - for (ar = sa1->regionbase.first; ar; ar = ar->next) - BKE_area_region_free(st, ar); - BLI_freelistN(&sa1->regionbase); - } - + + if (swap_space != 1) { st = BKE_spacetype_from_id(sa2->spacetype); for (ar = sa2->regionbase.first; ar; ar = ar->next) { ARegion *newar = BKE_area_region_copy(st, ar); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index b10f521d25d..6263199cf4f 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1840,7 +1840,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) return NULL; } - area_copy_data(old, sa, 1); /* 1 = swap spacelist */ + area_copy_data(old, sa, 1); if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO; old->full = NULL; @@ -1887,7 +1887,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) /* copy area */ newa = newa->prev; - area_copy_data(newa, sa, 1); /* 1 = swap spacelist */ + area_copy_data(newa, sa, 1); sa->flag |= AREA_TEMP_INFO; sa->full = oldscreen; diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index b279ddab42f..de04f8e3a0f 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -38,7 +38,7 @@ struct Scene; #define AZONESPOT (0.6f * U.widget_unit) /* area.c */ -void area_copy_data(ScrArea *sa1, ScrArea *sa2, const bool swap_space); +void area_copy_data(ScrArea *sa1, ScrArea *sa2, const char swap_space); void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade); /* screen_edit.c */ |