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
This commit is contained in:
Julian Eisel
2019-08-14 15:51:54 +02:00
parent 03b2371387
commit b7f86ff722

View File

@@ -225,12 +225,15 @@ static const EnumPropertyItem *rna_Area_ui_type_itemf(bContext *C,
static int rna_Area_ui_type_get(PointerRNA *ptr) static int rna_Area_ui_type_get(PointerRNA *ptr)
{ {
int value = rna_Area_type_get(ptr) << 16;
ScrArea *sa = ptr->data; 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. */ /* sa->type can be NULL (when not yet initialized), try to do it now. */
/* Copied from `ED_area_initialize()`.*/ /* Copied from `ED_area_initialize()`.*/
if (sa->type == NULL) { if (sa->type == NULL || area_changing) {
sa->type = BKE_spacetype_from_id(sa->spacetype); sa->type = BKE_spacetype_from_id(area_type);
if (sa->type == NULL) { if (sa->type == NULL) {
sa->spacetype = SPACE_VIEW3D; sa->spacetype = SPACE_VIEW3D;
sa->type = BKE_spacetype_from_id(sa->spacetype); 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); BLI_assert(sa->type != NULL);
} }
if (sa->type->space_subtype_item_extend != 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; return value;
} }