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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user