[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60443] trunk/blender/source/blender/ blenloader/intern/readfile.c: workaround for [#36314], ensure all id-properties are groups on load ( which are expected to be groups).

Campbell Barton ideasman42 at gmail.com
Mon Sep 30 15:44:16 CEST 2013


Revision: 60443
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60443
Author:   campbellbarton
Date:     2013-09-30 13:44:16 +0000 (Mon, 30 Sep 2013)
Log Message:
-----------
workaround for [#36314], ensure all id-properties are groups on load (which are expected to be groups).

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/intern/readfile.c

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2013-09-30 12:59:53 UTC (rev 60442)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2013-09-30 13:44:16 UTC (rev 60443)
@@ -1776,6 +1776,27 @@
 	}
 }
 
+#define IDP_DirectLinkGroup_OrFree(prop, switch_endian, fd) \
+       _IDP_DirectLinkGroup_OrFree(prop, switch_endian, fd, __func__)
+
+static void _IDP_DirectLinkGroup_OrFree(IDProperty **prop, int switch_endian, FileData *fd,
+                                        const char *caller_func_id)
+{
+	if (*prop) {
+		if ((*prop)->type == IDP_GROUP) {
+			IDP_DirectLinkGroup(*prop, switch_endian, fd);
+		}
+		else {
+			/* corrupt file! */
+			printf("%s: found non group data, freeing type %d!\n",
+			       caller_func_id, (*prop)->type);
+			/* don't risk id, data's likely corrupt. */
+			// IDP_FreeProperty(*prop);
+			*prop = NULL;
+		}
+	}
+}
+
 /* stub function */
 static void IDP_LibLinkProperty(IDProperty *UNUSED(prop), int UNUSED(switch_endian), FileData *UNUSED(fd))
 {
@@ -1788,9 +1809,8 @@
 	/*link direct data of ID properties*/
 	if (id->properties) {
 		id->properties = newdataadr(fd, id->properties);
-		if (id->properties) { /* this case means the data was written incorrectly, it should not happen */
-			IDP_DirectLinkProperty(id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
-		}
+		/* this case means the data was written incorrectly, it should not happen */
+		IDP_DirectLinkGroup_OrFree(&id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 	}
 }
 
@@ -2041,7 +2061,7 @@
 				FMod_Python *data = (FMod_Python *)fcm->data;
 				
 				data->prop = newdataadr(fd, data->prop);
-				IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+				IDP_DirectLinkGroup_OrFree(&data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 			}
 				break;
 		}
@@ -2596,8 +2616,7 @@
 static void direct_link_node_socket(FileData *fd, bNodeSocket *sock)
 {
 	sock->prop = newdataadr(fd, sock->prop);
-	if (sock->prop)
-		IDP_DirectLinkProperty(sock->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+	IDP_DirectLinkGroup_OrFree(&sock->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 	
 	sock->link = newdataadr(fd, sock->link);
 	sock->typeinfo = NULL;
@@ -2635,8 +2654,7 @@
 		link_list(fd, &node->outputs);
 		
 		node->prop = newdataadr(fd, node->prop);
-		if (node->prop)
-			IDP_DirectLinkProperty(node->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+		IDP_DirectLinkGroup_OrFree(&node->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 		
 		link_list(fd, &node->internal_links);
 		for (link = node->internal_links.first; link; link = link->next) {
@@ -2794,8 +2812,7 @@
 				link_list(fd, &data->targets);
 				
 				data->prop = newdataadr(fd, data->prop);
-				if (data->prop)
-					IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+				IDP_DirectLinkGroup_OrFree(&data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 				break;
 			}
 			case CONSTRAINT_TYPE_SPLINEIK:
@@ -2894,8 +2911,7 @@
 	
 	bone->parent = newdataadr(fd, bone->parent);
 	bone->prop = newdataadr(fd, bone->prop);
-	if (bone->prop)
-		IDP_DirectLinkProperty(bone->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+	IDP_DirectLinkGroup_OrFree(&bone->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 		
 	bone->flag &= ~BONE_DRAW_ACTIVE;
 	
@@ -4534,8 +4550,7 @@
 		direct_link_constraints(fd, &pchan->constraints);
 		
 		pchan->prop = newdataadr(fd, pchan->prop);
-		if (pchan->prop)
-			IDP_DirectLinkProperty(pchan->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+		IDP_DirectLinkGroup_OrFree(&pchan->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 		
 		pchan->mpath = newdataadr(fd, pchan->mpath);
 		if (pchan->mpath)
@@ -5432,10 +5447,7 @@
 	}
 	if (sce->r.ffcodecdata.properties) {
 		sce->r.ffcodecdata.properties = newdataadr(fd, sce->r.ffcodecdata.properties);
-		if (sce->r.ffcodecdata.properties) {
-			IDP_DirectLinkProperty(sce->r.ffcodecdata.properties, 
-				(fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
-		}
+		IDP_DirectLinkGroup_OrFree(&sce->r.ffcodecdata.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 	}
 	
 	link_list(fd, &(sce->markers));
@@ -6129,8 +6141,7 @@
 		ui_list->type = NULL;
 		ui_list->dyn_data = NULL;
 		ui_list->properties = newdataadr(fd, ui_list->properties);
-		if (ui_list->properties)
-			IDP_DirectLinkProperty(ui_list->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+		IDP_DirectLinkGroup_OrFree(&ui_list->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 	}
 
 	if (spacetype == SPACE_EMPTY) {
@@ -9756,8 +9767,7 @@
 static void direct_link_keymapitem(FileData *fd, wmKeyMapItem *kmi)
 {
 	kmi->properties = newdataadr(fd, kmi->properties);
-	if (kmi->properties)
-		IDP_DirectLinkProperty(kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+	IDP_DirectLinkGroup_OrFree(&kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 	kmi->ptr = NULL;
 	kmi->flag &= ~KMI_UPDATE;
 }
@@ -9814,9 +9824,7 @@
 
 	for (addon = user->addons.first; addon; addon = addon->next) {
 		addon->prop = newdataadr(fd, addon->prop);
-		if (addon->prop) {
-			IDP_DirectLinkProperty(addon->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
-		}
+		IDP_DirectLinkGroup_OrFree(&addon->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 	}
 
 	// XXX




More information about the Bf-blender-cvs mailing list