WM: add support for temporary region data

This commit is contained in:
2018-06-14 22:27:58 +02:00
parent 1adfabc8c6
commit 26786a2b87
4 changed files with 24 additions and 8 deletions

View File

@@ -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)

View File

@@ -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;
}
}
}
}

View File

@@ -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) {

View File

@@ -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 */