[Bf-blender-cvs] [26786a2b87a] blender2.8: WM: add support for temporary region data

Campbell Barton noreply at git.blender.org
Thu Jun 14 22:32:36 CEST 2018


Commit: 26786a2b87a08e239b7f255dc987ab70086bece0
Author: Campbell Barton
Date:   Thu Jun 14 22:27:58 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB26786a2b87a08e239b7f255dc987ab70086bece0

WM: add support for temporary region data

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

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 b6b49a49de3..2ccb2012a76 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -233,10 +233,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 2ec1aab3725..481acbb163d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6431,6 +6431,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) {
@@ -7213,11 +7217,12 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main
 
 					/* 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;
+							}
 						}
 					}
 				}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 71b13133230..0dafca67edc 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2687,6 +2687,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 efb3bf486bf..7fd0dbeb156 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -489,7 +489,9 @@ enum {
 	/* Force delayed reinit of region size data, so that region size is calculated
 	 * just big enough to show all its content (if enough space is available).
 	 * Note that only ED_region_header supports this right now. */
-	RGN_FLAG_DYNAMIC_SIZE     = (1 << 2),
+	RGN_FLAG_DYNAMIC_SIZE       = (1 << 2),
+	/* Region data is NULL'd on read, never written. */
+	RGN_FLAG_TEMP_REGIONDATA    = (1 << 3),
 };
 
 /* region do_draw */



More information about the Bf-blender-cvs mailing list