diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2018-04-22 20:58:27 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2018-04-23 00:23:20 +0300 |
commit | 9db492de6dd07dca93f0de7dbfa92f811fe50765 (patch) | |
tree | f7050e660a9d6deedfe6873875d042c90fa5cea2 /source/blender/makesrna/intern/rna_screen.c | |
parent | 9eaf00616ba60df92cfab2837dd175b8e7eb4c44 (diff) |
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`.
Diffstat (limited to 'source/blender/makesrna/intern/rna_screen.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_screen.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index cc711673c85..83d8e730e3e 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -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); |