diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-08-14 16:51:54 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-08-14 16:51:54 +0300 |
commit | b7f86ff72273ffa546c7b06bcebfed85fe67951d (patch) | |
tree | 396ddcec3814940e7ec07761a95a114de82ae3c9 /source/blender/makesrna/intern/rna_screen.c | |
parent | 03b2371387dcae9f801cabbc1819b1d7e3350829 (diff) |
Fix Area.ui_type invalid during area change
To reproduce:
* Split 3D View to show Info Editor
* Change 3D View a few times to various subtypes (Timeline, UV Editor
etc).
Every now and then, the Info Editor should show `UNKNOWN ENUM`. Other
prints may also be lagging behind.
Reviewed By: campbellbarton, brecht
Differential Revision: https://developer.blender.org/D5325
Diffstat (limited to 'source/blender/makesrna/intern/rna_screen.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_screen.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 853017e6daf..c868c79e968 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -225,12 +225,15 @@ static const EnumPropertyItem *rna_Area_ui_type_itemf(bContext *C, static int rna_Area_ui_type_get(PointerRNA *ptr) { - int value = rna_Area_type_get(ptr) << 16; ScrArea *sa = ptr->data; + const int area_type = rna_Area_type_get(ptr); + const bool area_changing = sa->butspacetype != SPACE_EMPTY; + int value = area_type << 16; + /* sa->type can be NULL (when not yet initialized), try to do it now. */ /* Copied from `ED_area_initialize()`.*/ - if (sa->type == NULL) { - sa->type = BKE_spacetype_from_id(sa->spacetype); + if (sa->type == NULL || area_changing) { + sa->type = BKE_spacetype_from_id(area_type); if (sa->type == NULL) { sa->spacetype = SPACE_VIEW3D; sa->type = BKE_spacetype_from_id(sa->spacetype); @@ -238,7 +241,7 @@ static int rna_Area_ui_type_get(PointerRNA *ptr) BLI_assert(sa->type != NULL); } if (sa->type->space_subtype_item_extend != NULL) { - value |= sa->type->space_subtype_get(sa); + value |= area_changing ? sa->butspacetype_subtype : sa->type->space_subtype_get(sa); } return value; } |