[Bf-blender-cvs] [8b10e1b4579] master: Fix T61780: Crash when trying to access screen areas through the outliner.

Bastien Montagne noreply at git.blender.org
Tue Mar 5 14:12:10 CET 2019


Commit: 8b10e1b45798b39fd63adef65f2eae0c7fbadbac
Author: Bastien Montagne
Date:   Tue Mar 5 14:06:19 2019 +0100
Branches: master
https://developer.blender.org/rB8b10e1b45798b39fd63adef65f2eae0c7fbadbac

Fix T61780: Crash when trying to access screen areas through the outliner.

ScreenArea->type is NULL-ified on read, and need to be initialized
(usually by `ED_area_initialize()`), but RNA can also access it before
it happens, so need to do it itself...

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

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 095aab53c10..0f363810ed2 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -256,6 +256,16 @@ static int rna_Area_ui_type_get(PointerRNA *ptr)
 {
 	int value = rna_Area_type_get(ptr) << 16;
 	ScrArea *sa = ptr->data;
+	/* 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) {
+			sa->spacetype = SPACE_VIEW3D;
+			sa->type = BKE_spacetype_from_id(sa->spacetype);
+		}
+		BLI_assert(sa->type != NULL);
+	}
 	if (sa->type->space_subtype_item_extend != NULL) {
 		value |= sa->type->space_subtype_get(sa);
 	}



More information about the Bf-blender-cvs mailing list