[Bf-blender-cvs] [cbc7ee28d7f] master: WM: 2.8 screen compatibility

Campbell Barton noreply at git.blender.org
Fri Jun 15 10:25:21 CEST 2018


Commit: cbc7ee28d7fe145564ca6c398a99e0519d97010d
Author: Campbell Barton
Date:   Fri Jun 15 10:23:03 2018 +0200
Branches: master
https://developer.blender.org/rBcbc7ee28d7fe145564ca6c398a99e0519d97010d

WM: 2.8 screen compatibility

Without these minor changes loading files from 2.8 will crash.

Manually applied edits from 26786a2b87a08

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

M	source/blender/blenkernel/intern/screen.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/makesdna/DNA_screen_types.h

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

diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index a719cc8c94a..995d22c9ba5 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -68,13 +68,17 @@ static void spacetype_free(SpaceType *st)
 	for (art = st->regiontypes.first; art; art = art->next) {
 		BLI_freelistN(&art->drawcalls);
 
-		for (pt = art->paneltypes.first; pt; pt = pt->next)
-			if (pt->ext.free)
+		for (pt = art->paneltypes.first; pt; pt = pt->next) {
+			if (pt->ext.free) {
 				pt->ext.free(pt->ext.data);
+			}
+		}
 
-		for (ht = art->headertypes.first; ht; ht = ht->next)
-			if (ht->ext.free)
+		for (ht = art->headertypes.first; ht; ht = ht->next) {
+			if (ht->ext.free) {
 				ht->ext.free(ht->ext.data);
+			}
+		}
 
 		BLI_freelistN(&art->paneltypes);
 		BLI_freelistN(&art->headertypes);
@@ -199,10 +203,15 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
 	if (ar->regiondata) {
 		ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
 
-		if (art && art->duplicate)
+		if (art && art->duplicate) {
 			newar->regiondata = art->duplicate(ar->regiondata);
-		else
+		}
+		else if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) {
+			newar->regiondata = NULL;
+		}
+		else {
 			newar->regiondata = MEM_dupallocN(ar->regiondata);
+		}
 	}
 
 	if (ar->v2d.tab_offset)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 937853463a2..7d3d417bf33 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6817,11 +6817,12 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc
 
 					/* free render engines for now */
 					for (ar = sa->regionbase.first; ar; ar = ar->next) {
-						RegionView3D *rv3d= ar->regiondata;
-						
-						if (rv3d && rv3d->render_engine) {
-							RE_engine_free(rv3d->render_engine);
-							rv3d->render_engine = NULL;
+						if (ar->regiontype == RGN_TYPE_WINDOW) {
+							RegionView3D *rv3d = ar->regiondata;
+							if (rv3d && rv3d->render_engine) {
+								RE_engine_free(rv3d->render_engine);
+								rv3d->render_engine = NULL;
+							}
 						}
 					}
 				}
@@ -7051,6 +7052,10 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
 		/* unkown space type, don't leak regiondata */
 		ar->regiondata = NULL;
 	}
+	else if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) {
+		/* Runtime data, don't use. */
+		ar->regiondata = NULL;
+	}
 	else {
 		ar->regiondata = newdataadr(fd, ar->regiondata);
 		if (ar->regiondata) {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 88e6cbc8d24..0e67bde6883 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2825,6 +2825,10 @@ static void write_region(WriteData *wd, ARegion *ar, int spacetype)
 	writestruct(wd, DATA, ARegion, 1, ar);
 
 	if (ar->regiondata) {
+		if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) {
+			return;
+		}
+
 		switch (spacetype) {
 			case SPACE_VIEW3D:
 				if (ar->regiontype == RGN_TYPE_WINDOW) {
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index a7718883438..a9767f506dc 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -53,10 +53,10 @@ typedef struct bScreen {
 	ListBase edgebase;
 	ListBase areabase;
 	ListBase regionbase;				/* screen level regions (menus), runtime only */
-	
+
 	struct Scene *scene;
 	struct Scene *newscene;				/* temporary when switching */
-	
+
 	short winid;						/* winid from WM, starts with 1 */
 	short redraws_flag;					/* user-setting for which editors get redrawn during anim playback (used to be time->redraws) */
 
@@ -384,7 +384,7 @@ enum {
 	RGN_TYPE_UI = 4,
 	RGN_TYPE_TOOLS = 5,
 	RGN_TYPE_TOOL_PROPS = 6,
-	RGN_TYPE_PREVIEW = 7
+	RGN_TYPE_PREVIEW = 7,
 };
 /* use for function args */
 #define RGN_TYPE_ANY -1
@@ -403,8 +403,12 @@ enum {
 #define RGN_SPLIT_PREV		32
 
 /* region flag */
-#define RGN_FLAG_HIDDEN		1
-#define RGN_FLAG_TOO_SMALL	2
+enum {
+	RGN_FLAG_HIDDEN             = (1 << 0),
+	RGN_FLAG_TOO_SMALL          = (1 << 1),
+	/* Region data is NULL'd on read, never written. */
+	RGN_FLAG_TEMP_REGIONDATA    = (1 << 3),
+};
 
 /* region do_draw */
 #define RGN_DRAW			1



More information about the Bf-blender-cvs mailing list