[Bf-blender-cvs] [b7f86ff7227] master: Fix Area.ui_type invalid during area change

Julian Eisel noreply at git.blender.org
Wed Aug 14 15:52:44 CEST 2019


Commit: b7f86ff72273ffa546c7b06bcebfed85fe67951d
Author: Julian Eisel
Date:   Wed Aug 14 15:51:54 2019 +0200
Branches: master
https://developer.blender.org/rBb7f86ff72273ffa546c7b06bcebfed85fe67951d

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

===================================================================

M	source/blender/makesrna/intern/rna_screen.c

===================================================================

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;
 }



More information about the Bf-blender-cvs mailing list