[Bf-blender-cvs] [2a8ba9c08ec] blender-v2.83-release: Fix T76471: timer not removed after changing file browser to another type

Brecht Van Lommel noreply at git.blender.org
Fri May 8 01:55:37 CEST 2020


Commit: 2a8ba9c08ec91d73a9c1f59b90aa9e9e37e492d8
Author: Brecht Van Lommel
Date:   Fri May 8 01:47:35 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB2a8ba9c08ec91d73a9c1f59b90aa9e9e37e492d8

Fix T76471: timer not removed after changing file browser to another type

The file browser exit() callback was not called. RNA get functions should never
modify data, here the area type info to be changed before the screen and area
were properly updated.

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

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 d9e3003c6f3..20ae69dc031 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -218,18 +218,22 @@ static int rna_Area_ui_type_get(PointerRNA *ptr)
   const bool area_changing = area->butspacetype != SPACE_EMPTY;
   int value = area_type << 16;
 
-  /* area->type can be NULL (when not yet initialized), try to do it now. */
-  /* Copied from `ED_area_initialize()`.*/
-  if (area->type == NULL || area_changing) {
-    area->type = BKE_spacetype_from_id(area_type);
-    if (area->type == NULL) {
-      area->spacetype = SPACE_VIEW3D;
-      area->type = BKE_spacetype_from_id(area->spacetype);
+  /* Area->type can be NULL when not yet initialized (for example when accessed
+   * through the outliner or API when not visible), or it can be wrong while
+   * the area type is changing.
+   * So manually do the lookup in those cases, but do not actually change area->type
+   * since that prevents a proper exit when the area type is changing.
+   * Logic copied from `ED_area_initialize()`.*/
+  SpaceType *type = area->type;
+  if (type == NULL || area_changing) {
+    type = BKE_spacetype_from_id(area_type);
+    if (type == NULL) {
+      type = BKE_spacetype_from_id(SPACE_VIEW3D);
     }
-    BLI_assert(area->type != NULL);
+    BLI_assert(type != NULL);
   }
-  if (area->type->space_subtype_item_extend != NULL) {
-    value |= area_changing ? area->butspacetype_subtype : area->type->space_subtype_get(area);
+  if (type->space_subtype_item_extend != NULL) {
+    value |= area_changing ? area->butspacetype_subtype : type->space_subtype_get(area);
   }
   return value;
 }



More information about the Bf-blender-cvs mailing list