[Bf-blender-cvs] [e54caf76cbe] master: Fix T52663: Remap used invalid local-view data

Campbell Barton noreply at git.blender.org
Wed Sep 6 12:51:22 CEST 2017


Commit: e54caf76cbe94e488ed2c539b0c108ab0618d2e2
Author: Campbell Barton
Date:   Wed Sep 6 20:52:49 2017 +1000
Branches: master
https://developer.blender.org/rBe54caf76cbe94e488ed2c539b0c108ab0618d2e2

Fix T52663: Remap used invalid local-view data

Only the camera from View3D.localvd is used,
other pointers may be invalid.

Longer term we should probably clear these to ensure no accidents.
For now just follow the rest of Blender's code and don't access.

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

M	source/blender/editors/space_view3d/space_view3d.c

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

diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index b8228c63209..d993f91d7fb 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1412,33 +1412,33 @@ static void view3d_id_remap(ScrArea *sa, SpaceLink *slink, ID *old_id, ID *new_i
 				}
 			}
 		}
-		if ((ID *)v3d->ob_centre == old_id) {
-			v3d->ob_centre = (Object *)new_id;
-			if (new_id == NULL) {  /* Otherwise, bonename may remain valid... We could be smart and check this, too? */
-				v3d->ob_centre_bone[0] = '\0';
-			}
-		}
 
-		if ((ID *)v3d->defmaterial == old_id) {
-			v3d->defmaterial = (Material *)new_id;
-		}
-#if 0  /* XXX Deprecated? */
-		if ((ID *)v3d->gpd == old_id) {
-			v3d->gpd = (bGPData *)new_id;
-		}
-#endif
+		/* Values in local-view aren't used, see: T52663 */
+		if (is_local == false) {
+			if ((ID *)v3d->defmaterial == old_id) {
+				v3d->defmaterial = (Material *)new_id;
+			}
 
-		if (ELEM(GS(old_id->name), ID_IM, ID_MC)) {
-			for (BGpic *bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
-				if ((ID *)bgpic->ima == old_id) {
-					bgpic->ima = (Image *)new_id;
-					id_us_min(old_id);
-					id_us_plus(new_id);
+			if ((ID *)v3d->ob_centre == old_id) {
+				v3d->ob_centre = (Object *)new_id;
+				/* Otherwise, bonename may remain valid... We could be smart and check this, too? */
+				if (new_id == NULL) {
+					v3d->ob_centre_bone[0] = '\0';
 				}
-				if ((ID *)bgpic->clip == old_id) {
-					bgpic->clip = (MovieClip *)new_id;
-					id_us_min(old_id);
-					id_us_plus(new_id);
+			}
+
+			if (ELEM(GS(old_id->name), ID_IM, ID_MC)) {
+				for (BGpic *bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
+					if ((ID *)bgpic->ima == old_id) {
+						bgpic->ima = (Image *)new_id;
+						id_us_min(old_id);
+						id_us_plus(new_id);
+					}
+					if ((ID *)bgpic->clip == old_id) {
+						bgpic->clip = (MovieClip *)new_id;
+						id_us_min(old_id);
+						id_us_plus(new_id);
+					}
 				}
 			}
 		}



More information about the Bf-blender-cvs mailing list