From 6ee2d10005a9e3f47ba6eed53d4e56b9e76f9842 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 17 Sep 2019 13:08:37 +0200 Subject: [PATCH] Fix T69974: crashes in .blend files where 3D viewport was split This was caused by a missing copy of the recently adding 3D viewport shading ID properties. --- source/blender/blenkernel/intern/scene.c | 4 +++ .../blenloader/intern/versioning_280.c | 25 ++++++++++++++++++- .../editors/space_view3d/space_view3d.c | 4 +++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 71668f77efe..faf3d12fdad 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -318,6 +318,10 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons flag_subdata); } + if (sce_src->display.shading.prop) { + sce_dst->display.shading.prop = IDP_CopyProperty(sce_src->display.shading.prop); + } + BKE_sound_reset_scene_runtime(sce_dst); /* Copy sequencer, this is local data! */ diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 62428690206..074809d10c4 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3856,7 +3856,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) { /* Versioning code until next subversion bump goes here. */ - if (!DNA_struct_elem_find( fd->filesdna, "LayerCollection", "short", "local_collections_bits")) { LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { @@ -3867,5 +3866,29 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + /* Fix wrong 3D viewport copying causing corrupt pointers (T69974). */ + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + + for (ScrArea *sa_other = screen->areabase.first; sa_other; sa_other = sa_other->next) { + for (SpaceLink *sl_other = sa_other->spacedata.first; sl_other; + sl_other = sl_other->next) { + if (sl != sl_other && sl_other->spacetype == SPACE_VIEW3D) { + View3D *v3d_other = (View3D *)sl_other; + + if (v3d->shading.prop == v3d_other->shading.prop) { + v3d_other->shading.prop = NULL; + } + } + } + } + } + } + } + } } } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index cfd0bf9a012..f398a122e61 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -345,6 +345,10 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl) v3dn->shading.type = OB_SOLID; } + if (v3dn->shading.prop) { + v3dn->shading.prop = IDP_CopyProperty(v3do->shading.prop); + } + /* copy or clear inside new stuff */ v3dn->runtime.properties_storage = NULL;