Cleanup: Get rid of ScrArea.butspacetype syncing with ScrArea.spacetype
The only real reason we need `butspacetype` is while switching areas, where we need to delay the actual switch to the RNA _update callback since only there we can access context. So instead of trying to sync it with `spacetype`, only set while needed and unset it afterwards (as in set to `SPACE_EMPTY`). This should also allow us to re-use `butspacetype` in versioning code when trying to read removed editors. It'll store the space type value of the removed editor which we can then use on versioning. For backwards compatibility, we store `butspacetype` with the value of `spacetype`.
This commit is contained in:
parent
9eaf00616b
commit
9db492de6d
|
@ -6394,6 +6394,7 @@ static void direct_link_area(FileData *fd, ScrArea *area)
|
|||
|
||||
BLI_listbase_clear(&area->handlers);
|
||||
area->type = NULL; /* spacetype callbacks */
|
||||
area->butspacetype = SPACE_EMPTY; /* Should always be unset so that rna_Area_type_get works correctly */
|
||||
area->region_active_win = -1;
|
||||
|
||||
area->global = newdataadr(fd, area->global);
|
||||
|
@ -6420,9 +6421,6 @@ static void direct_link_area(FileData *fd, ScrArea *area)
|
|||
blo_do_versions_view3d_split_250(area->spacedata.first, &area->regionbase);
|
||||
}
|
||||
|
||||
/* incase we set above */
|
||||
area->butspacetype = area->spacetype;
|
||||
|
||||
for (sl = area->spacedata.first; sl; sl = sl->next) {
|
||||
link_list(fd, &(sl->regionbase));
|
||||
|
||||
|
|
|
@ -429,9 +429,6 @@ static void do_versions_windowmanager_2_50(bScreen *screen)
|
|||
sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
|
||||
}
|
||||
|
||||
/* it seems to be possible in 2.5 to have this saved, filewindow probably */
|
||||
sa->butspacetype = sa->spacetype;
|
||||
|
||||
/* pushed back spaces also need regions! */
|
||||
if (sa->spacedata.first) {
|
||||
sl = sa->spacedata.first;
|
||||
|
|
|
@ -2898,6 +2898,8 @@ static void write_area_map(WriteData *wd, ScrAreaMap *area_map)
|
|||
writelist(wd, DATA, ScrVert, &area_map->vertbase);
|
||||
writelist(wd, DATA, ScrEdge, &area_map->edgebase);
|
||||
for (ScrArea *area = area_map->areabase.first; area; area = area->next) {
|
||||
area->butspacetype = area->spacetype; /* Just for compatibility, will be reset below. */
|
||||
|
||||
writestruct(wd, DATA, ScrArea, 1, area);
|
||||
|
||||
#ifdef WITH_TOPBAR_WRITING
|
||||
|
@ -2905,6 +2907,8 @@ static void write_area_map(WriteData *wd, ScrAreaMap *area_map)
|
|||
#endif
|
||||
|
||||
write_area_regions(wd, area);
|
||||
|
||||
area->butspacetype = SPACE_EMPTY; /* Unset again, was changed above. */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1481,10 +1481,10 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
|
|||
sa->type = BKE_spacetype_from_id(sa->spacetype);
|
||||
|
||||
if (sa->type == NULL) {
|
||||
sa->butspacetype = sa->spacetype = SPACE_VIEW3D;
|
||||
sa->spacetype = SPACE_VIEW3D;
|
||||
sa->type = BKE_spacetype_from_id(sa->spacetype);
|
||||
}
|
||||
|
||||
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
||||
ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype);
|
||||
|
||||
|
@ -1607,7 +1607,6 @@ void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free)
|
|||
sa_dst->headertype = sa_src->headertype;
|
||||
sa_dst->spacetype = sa_src->spacetype;
|
||||
sa_dst->type = sa_src->type;
|
||||
sa_dst->butspacetype = sa_src->butspacetype;
|
||||
|
||||
sa_dst->flag = (sa_dst->flag & ~flag_copy) | (sa_src->flag & flag_copy);
|
||||
|
||||
|
@ -1638,7 +1637,6 @@ void ED_area_data_swap(ScrArea *sa_dst, ScrArea *sa_src)
|
|||
SWAP(short, sa_dst->headertype, sa_src->headertype);
|
||||
SWAP(char, sa_dst->spacetype, sa_src->spacetype);
|
||||
SWAP(SpaceType *, sa_dst->type, sa_src->type);
|
||||
SWAP(char, sa_dst->butspacetype, sa_src->butspacetype);
|
||||
|
||||
|
||||
SWAP(ListBase, sa_dst->spacedata, sa_src->spacedata);
|
||||
|
@ -1677,8 +1675,9 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2)
|
|||
*/
|
||||
void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exit)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
if (sa->spacetype != type) {
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
SpaceType *st;
|
||||
SpaceLink *slold;
|
||||
SpaceLink *sl;
|
||||
|
@ -1702,7 +1701,6 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
|
|||
slold = sa->spacedata.first;
|
||||
|
||||
sa->spacetype = type;
|
||||
sa->butspacetype = type;
|
||||
sa->type = st;
|
||||
|
||||
/* If st->new may be called, don't use context until then. The
|
||||
|
|
|
@ -179,7 +179,7 @@ static ScrArea *screen_addarea_ex(
|
|||
sa->v3 = top_right;
|
||||
sa->v4 = bottom_right;
|
||||
sa->headertype = headertype;
|
||||
sa->spacetype = sa->butspacetype = spacetype;
|
||||
sa->spacetype = spacetype;
|
||||
|
||||
BLI_addtail(&area_map->areabase, sa);
|
||||
|
||||
|
|
|
@ -251,7 +251,11 @@ typedef struct ScrArea {
|
|||
|
||||
rcti totrct; /* rect bound by v1 v2 v3 v4 */
|
||||
|
||||
char spacetype, butspacetype; /* SPACE_..., butspacetype is button arg */
|
||||
char spacetype; /* eSpace_Type (SPACE_FOO) */
|
||||
/* Temporarily used while switching area type, otherwise this should be
|
||||
* SPACE_EMPTY. It's been there for ages, name doesn't fit any more. */
|
||||
char butspacetype; /* eSpace_Type (SPACE_FOO) */
|
||||
|
||||
short winx, winy; /* size */
|
||||
|
||||
short headertype; /* OLD! 0=no header, 1= down, 2= up */
|
||||
|
|
|
@ -159,8 +159,9 @@ static const EnumPropertyItem *rna_Area_type_itemf(bContext *UNUSED(C), PointerR
|
|||
static int rna_Area_type_get(PointerRNA *ptr)
|
||||
{
|
||||
ScrArea *sa = (ScrArea *)ptr->data;
|
||||
/* read from this instead of 'spacetype' for correct reporting: T41435 */
|
||||
return sa->butspacetype;
|
||||
/* Usually 'spacetype' is used. It lags behind a bit while switching area
|
||||
* type though, then we use 'butspacetype' instead (T41435). */
|
||||
return (sa->butspacetype == SPACE_EMPTY) ? sa->spacetype : sa->butspacetype;
|
||||
}
|
||||
|
||||
static void rna_Area_type_set(PointerRNA *ptr, int value)
|
||||
|
@ -197,6 +198,9 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr)
|
|||
ED_area_newspace(C, sa, sa->butspacetype, true);
|
||||
ED_area_tag_redraw(sa);
|
||||
|
||||
/* Unset so that rna_Area_type_get uses spacetype instead. */
|
||||
sa->butspacetype = SPACE_EMPTY;
|
||||
|
||||
/* It is possible that new layers becomes visible. */
|
||||
if (sa->spacetype == SPACE_VIEW3D) {
|
||||
DEG_on_visible_update(CTX_data_main(C), false);
|
||||
|
|
Loading…
Reference in New Issue