diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-14 23:27:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-14 23:27:58 +0300 |
commit | 26786a2b87a08e239b7f255dc987ab70086bece0 (patch) | |
tree | 033d826ae5cdc946624639687d80e4c42ef6b7e9 | |
parent | 1adfabc8c62ed3f067d209511ce3d868e76c9bbd (diff) |
WM: add support for temporary region data
-rw-r--r-- | source/blender/blenkernel/intern/screen.c | 9 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 15 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_screen_types.h | 4 |
4 files changed, 24 insertions, 8 deletions
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 */ |