[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43283] trunk/blender/source/blender: Longer names support for all ID and other object names

Sergey Sharybin sergey.vfx at gmail.com
Wed Jan 11 09:51:17 CET 2012


Revision: 43283
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43283
Author:   nazgul
Date:     2012-01-11 08:51:06 +0000 (Wed, 11 Jan 2012)
Log Message:
-----------
Longer names support for all ID and other object names

This commit extends limit of ID and objects to 64 (it means 63 meaning
characters and 1 for zero-terminator). CustomData layers names are also
extended.
Changed DNA structures and all places where length constants were hardcoded.

All names which are "generating" from ID block should be limited by MAX_ID_NAME-2,
all non-id names now has got own define called MAX_NAME which should be used all
over for non-id names to make further name migration stuff easier.

All name fields in DNA now have comment with constant which corresponds to
hardcoded numeric value which should make it easier to further update this
limits or even switch to non-hardcoded values in DNA.

Special thanks to Campbell who helped figuring out some issues and helped a lot
in finding all cases where hardcoded valued were still used in code.

Both of forwards and backwards compatibility is stored with blender versions newer
than January 5, 2011. Older versions had issue with placing null-terminator to
DNA strings on file load which will lead to some unpredictable behavior or even
crashes.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_armature.h
    trunk/blender/source/blender/blenkernel/BKE_deform.h
    trunk/blender/source/blender/blenkernel/BKE_node.h
    trunk/blender/source/blender/blenkernel/BKE_sequencer.h
    trunk/blender/source/blender/blenkernel/intern/customdata.c
    trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c
    trunk/blender/source/blender/blenkernel/intern/library.c
    trunk/blender/source/blender/blenkernel/intern/mball.c
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/blenkernel/intern/seqeffects.c
    trunk/blender/source/blender/blenkernel/intern/sequencer.c
    trunk/blender/source/blender/blenkernel/intern/sound.c
    trunk/blender/source/blender/blenkernel/intern/tracking.c
    trunk/blender/source/blender/editors/armature/editarmature.c
    trunk/blender/source/blender/editors/armature/editarmature_retarget.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/include/ED_armature.h
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/interface/interface_layout.c
    trunk/blender/source/blender/editors/interface/interface_templates.c
    trunk/blender/source/blender/editors/mesh/mesh_data.c
    trunk/blender/source/blender/editors/object/object_add.c
    trunk/blender/source/blender/editors/object/object_constraint.c
    trunk/blender/source/blender/editors/object/object_edit.c
    trunk/blender/source/blender/editors/object/object_group.c
    trunk/blender/source/blender/editors/object/object_hook.c
    trunk/blender/source/blender/editors/object/object_modifier.c
    trunk/blender/source/blender/editors/object/object_ops.c
    trunk/blender/source/blender/editors/object/object_relations.c
    trunk/blender/source/blender/editors/object/object_select.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
    trunk/blender/source/blender/editors/space_logic/logic_ops.c
    trunk/blender/source/blender/editors/space_logic/logic_window.c
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/editors/space_node/node_edit.c
    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
    trunk/blender/source/blender/editors/transform/transform.h
    trunk/blender/source/blender/editors/transform/transform_ops.c
    trunk/blender/source/blender/editors/transform/transform_orientations.c
    trunk/blender/source/blender/gpu/GPU_extensions.h
    trunk/blender/source/blender/makesdna/DNA_ID.h
    trunk/blender/source/blender/makesdna/DNA_action_types.h
    trunk/blender/source/blender/makesdna/DNA_actuator_types.h
    trunk/blender/source/blender/makesdna/DNA_armature_types.h
    trunk/blender/source/blender/makesdna/DNA_constraint_types.h
    trunk/blender/source/blender/makesdna/DNA_controller_types.h
    trunk/blender/source/blender/makesdna/DNA_customdata_types.h
    trunk/blender/source/blender/makesdna/DNA_defs.h
    trunk/blender/source/blender/makesdna/DNA_dynamicpaint_types.h
    trunk/blender/source/blender/makesdna/DNA_effect_types.h
    trunk/blender/source/blender/makesdna/DNA_key_types.h
    trunk/blender/source/blender/makesdna/DNA_lattice_types.h
    trunk/blender/source/blender/makesdna/DNA_material_types.h
    trunk/blender/source/blender/makesdna/DNA_modifier_types.h
    trunk/blender/source/blender/makesdna/DNA_node_types.h
    trunk/blender/source/blender/makesdna/DNA_object_force.h
    trunk/blender/source/blender/makesdna/DNA_object_types.h
    trunk/blender/source/blender/makesdna/DNA_particle_types.h
    trunk/blender/source/blender/makesdna/DNA_property_types.h
    trunk/blender/source/blender/makesdna/DNA_scene_types.h
    trunk/blender/source/blender/makesdna/DNA_sensor_types.h
    trunk/blender/source/blender/makesdna/DNA_sequence_types.h
    trunk/blender/source/blender/makesdna/DNA_texture_types.h
    trunk/blender/source/blender/makesdna/DNA_tracking_types.h
    trunk/blender/source/blender/makesdna/DNA_view3d_types.h
    trunk/blender/source/blender/makesdna/DNA_windowmanager_types.h
    trunk/blender/source/blender/makesrna/intern/rna_modifier.c
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
    trunk/blender/source/blender/makesrna/intern/rna_tracking.c
    trunk/blender/source/blender/modifiers/intern/MOD_armature.c
    trunk/blender/source/blender/modifiers/intern/MOD_bevel.c
    trunk/blender/source/blender/modifiers/intern/MOD_cast.c
    trunk/blender/source/blender/modifiers/intern/MOD_curve.c
    trunk/blender/source/blender/modifiers/intern/MOD_displace.c
    trunk/blender/source/blender/modifiers/intern/MOD_hook.c
    trunk/blender/source/blender/modifiers/intern/MOD_lattice.c
    trunk/blender/source/blender/modifiers/intern/MOD_smooth.c
    trunk/blender/source/blender/modifiers/intern/MOD_util.c
    trunk/blender/source/blender/modifiers/intern/MOD_uvproject.c
    trunk/blender/source/blender/modifiers/intern/MOD_wave.c
    trunk/blender/source/blender/modifiers/intern/MOD_weightvg_util.c
    trunk/blender/source/blender/modifiers/intern/MOD_weightvg_util.h
    trunk/blender/source/blender/nodes/composite/node_composite_tree.c
    trunk/blender/source/blender/nodes/texture/nodes/node_texture_output.c
    trunk/blender/source/blender/python/generic/bpy_internal_import.c
    trunk/blender/source/blender/python/generic/idprop_py_api.c
    trunk/blender/source/blender/render/intern/include/render_types.h

Modified: trunk/blender/source/blender/blenkernel/BKE_armature.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_armature.h	2012-01-11 07:27:39 UTC (rev 43282)
+++ trunk/blender/source/blender/blenkernel/BKE_armature.h	2012-01-11 08:51:06 UTC (rev 43283)
@@ -82,7 +82,7 @@
 void make_local_armature(struct bArmature *arm);
 struct bArmature *copy_armature(struct bArmature *arm);
 
-int bone_autoside_name (char name[32], int strip_number, short axis, float head, float tail);
+int bone_autoside_name (char name[64], int strip_number, short axis, float head, float tail);
 
 struct Bone *get_named_bone (struct bArmature *arm, const char *name);
 

Modified: trunk/blender/source/blender/blenkernel/BKE_deform.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_deform.h	2012-01-11 07:27:39 UTC (rev 43282)
+++ trunk/blender/source/blender/blenkernel/BKE_deform.h	2012-01-11 08:51:06 UTC (rev 43283)
@@ -69,7 +69,7 @@
 
 /* utility function, note that 32 chars is the maximum string length since its only
  * used with defgroups currently */
-void flip_side_name(char name[32], const char from_name[32], int strip_number);
+void flip_side_name(char name[64], const char from_name[64], int strip_number);
 
 #endif
 

Modified: trunk/blender/source/blender/blenkernel/BKE_node.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_node.h	2012-01-11 07:27:39 UTC (rev 43282)
+++ trunk/blender/source/blender/blenkernel/BKE_node.h	2012-01-11 08:51:06 UTC (rev 43283)
@@ -76,7 +76,7 @@
  */
 typedef struct bNodeSocketTemplate {
 	int type, limit;
-	char name[32];
+	char name[64];	/* MAX_NAME */
 	float val1, val2, val3, val4;   /* default alloc value for inputs */
 	float min, max;
 	PropertySubType subtype;
@@ -95,7 +95,7 @@
  */
 typedef struct bNodeSocketType {
 	int type;
-	char ui_name[32];
+	char ui_name[64];	/* MAX_NAME */
 	char ui_description[128];
 	int ui_icon;
 	char ui_color[4];
@@ -125,7 +125,7 @@
 	short needs_free;		/* set for allocated types that need to be freed */
 	
 	int type;
-	char name[32];
+	char name[64];	/* MAX_NAME */
 	float width, minwidth, maxwidth;
 	float height, minheight, maxheight;
 	short nclass, flag, compatibility;

Modified: trunk/blender/source/blender/blenkernel/BKE_sequencer.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_sequencer.h	2012-01-11 07:27:39 UTC (rev 43282)
+++ trunk/blender/source/blender/blenkernel/BKE_sequencer.h	2012-01-11 08:51:06 UTC (rev 43283)
@@ -306,7 +306,7 @@
 	int tot_error;
 	int len;		/* only for image strips */
 	char path[512];
-	char name[32];
+	char name[64];
 } SeqLoadInfo;
 
 /* SeqLoadInfo.flag */

Modified: trunk/blender/source/blender/blenkernel/intern/customdata.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/customdata.c	2012-01-11 07:27:39 UTC (rev 43282)
+++ trunk/blender/source/blender/blenkernel/intern/customdata.c	2012-01-11 08:51:06 UTC (rev 43283)
@@ -1519,7 +1519,7 @@
 	data->layers[index].data = newlayerdata;
 
 	if(name || (name=typeInfo->defaultname)) {
-		BLI_strncpy(data->layers[index].name, name, 32);
+		BLI_strncpy(data->layers[index].name, name, sizeof(data->layers[index].name));
 		CustomData_set_layer_unique_name(data, index);
 	}
 	else

Modified: trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c	2012-01-11 07:27:39 UTC (rev 43282)
+++ trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c	2012-01-11 08:51:06 UTC (rev 43283)
@@ -1323,7 +1323,7 @@
 		MTFace *tface;
 		MFace *mface = dm->getFaceArray(dm);
 		int numOfFaces = dm->getNumFaces(dm);
-		char uvname[40];
+		char uvname[MAX_CUSTOMDATA_LAYER_NAME];
 
 		if (!tex) return;
 
@@ -2079,7 +2079,7 @@
 	int ty;
 	int w,h;
 	int numOfFaces;
-	char uvname[32];
+	char uvname[MAX_CUSTOMDATA_LAYER_NAME];
 	int active_points = 0;
 	int error = 0;
 

Modified: trunk/blender/source/blender/blenkernel/intern/library.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/library.c	2012-01-11 07:27:39 UTC (rev 43282)
+++ trunk/blender/source/blender/blenkernel/intern/library.c	2012-01-11 08:51:06 UTC (rev 43283)
@@ -1136,10 +1136,12 @@
 {
 	ID *idtest;
 	int nr= 0, nrtest, a, left_len;
-	char left[32], leftest[32], in_use[32];
+	char in_use[64]; /* use as a boolean array, unrelated to name length */
 
+	char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8];
+
 	/* make sure input name is terminated properly */
-	/* if( strlen(name) > 21 ) name[21]= 0; */
+	/* if( strlen(name) > MAX_ID_NAME-3 ) name[MAX_ID_NAME-3]= 0; */
 	/* removed since this is only ever called from one place - campbell */
 
 	while (1) {
@@ -1151,20 +1153,20 @@
 		if( idtest == NULL ) return 0;
 
 		/* we have a dup; need to make a new name */
-		/* quick check so we can reuse one of first 32 ids if vacant */
+		/* quick check so we can reuse one of first 64 ids if vacant */
 		memset(in_use, 0, sizeof(in_use));
 
 		/* get name portion, number portion ("name.number") */
 		left_len= BLI_split_name_num(left, &nr, name, '.');
 
 		/* if new name will be too long, truncate it */
-		if(nr > 999 && left_len > 16) {
-			left[16]= 0;
-			left_len= 16;
+		if(nr > 999 && left_len > (MAX_ID_NAME - 8)) {
+			left[MAX_ID_NAME - 8]= 0;
+			left_len= MAX_ID_NAME - 8;
 		}
-		else if(left_len > 17) {
-			left[17]= 0;
-			left_len= 17;
+		else if(left_len > (MAX_ID_NAME - 7)) {
+			left[MAX_ID_NAME - 7]= 0;
+			left_len= MAX_ID_NAME - 7;
 		}
 
 		for(idtest= lb->first; idtest; idtest= idtest->next) {
@@ -1206,11 +1208,11 @@
 			/* otherwise just continue and use a number suffix */
 		}
 		
-		if(nr > 999 && left_len > 16) {
+		if(nr > 999 && left_len > (MAX_ID_NAME - 8)) {
 			/* this would overflow name buffer */
-			left[16] = 0;
-			/* left_len = 16; */ /* for now this isnt used again */
-			memcpy(name, left, sizeof(char) * 17);
+			left[MAX_ID_NAME - 8] = 0;
+			/* left_len = MAX_ID_NAME - 8; */ /* for now this isnt used again */
+			memcpy(name, left, sizeof(char) * (MAX_ID_NAME - 7));
 			continue;
 		}
 		/* this format specifier is from hell... */
@@ -1245,7 +1247,7 @@
 
 	strncpy(name, tname, sizeof(name)-1);
 
-	/* if result > 21, strncpy don't put the final '\0' to name.
+	/* if result > MAX_ID_NAME-3, strncpy don't put the final '\0' to name.
 	 * easier to assign each time then to check if its needed */
 	name[sizeof(name)-1]= 0;
 

Modified: trunk/blender/source/blender/blenkernel/intern/mball.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mball.c	2012-01-11 07:27:39 UTC (rev 43282)
+++ trunk/blender/source/blender/blenkernel/intern/mball.c	2012-01-11 08:51:06 UTC (rev 43283)
@@ -356,7 +356,7 @@
 int is_mball_basis_for(Object *ob1, Object *ob2)
 {
 	int basis1nr, basis2nr;
-	char basis1name[32], basis2name[32];
+	char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME];
 
 	BLI_split_name_num(basis1name, &basis1nr, ob1->id.name+2, '.');
 	BLI_split_name_num(basis2name, &basis2nr, ob2->id.name+2, '.');
@@ -378,7 +378,7 @@
 	Object *ob;
 	MetaBall *active_mball = (MetaBall*)active_object->data;
 	int basisnr, obnr;
-	char basisname[32], obname[32];
+	char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
 	
 	BLI_split_name_num(basisname, &basisnr, active_object->id.name+2, '.');
 
@@ -423,7 +423,7 @@
 	Object *ob,*bob= basis;
 	MetaElem *ml=NULL;
 	int basisnr, obnr;
-	char basisname[32], obname[32];
+	char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
 
 	BLI_split_name_num(basisname, &basisnr, basis->id.name+2, '.');
 	totelem= 0;
@@ -1596,7 +1596,7 @@
 	float size, totsize, obinv[4][4], obmat[4][4], vec[3];
 	//float max=0.0;
 	int a, obnr, zero_size=0;
-	char obname[32];
+	char obname[MAX_ID_NAME];
 	
 	copy_m4_m4(obmat, ob->obmat);	/* to cope with duplicators from next_object */
 	invert_m4_m4(obinv, ob->obmat);
@@ -1619,7 +1619,7 @@
 				else ml= mb->elems.first;
 			}
 			else {
-				char name[32];
+				char name[MAX_ID_NAME];
 				int nr;
 				
 				BLI_split_name_num(name, &nr, bob->id.name+2, '.');

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c	2012-01-11 07:27:39 UTC (rev 43282)
+++ trunk/blender/source/blender/blenkernel/intern/object.c	2012-01-11 08:51:06 UTC (rev 43283)
@@ -830,7 +830,7 @@
 {
 	Object *ob;
 	Base *base;
-	char name[32];
+	char name[MAX_ID_NAME];
 
 	BLI_strncpy(name, get_obdata_defname(type), sizeof(name));
 	ob = add_only_object(type, name);

Modified: trunk/blender/source/blender/blenkernel/intern/seqeffects.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/seqeffects.c	2012-01-11 07:27:39 UTC (rev 43282)
+++ trunk/blender/source/blender/blenkernel/intern/seqeffects.c	2012-01-11 08:51:06 UTC (rev 43283)
@@ -176,7 +176,7 @@
 				MEM_freeN(info);
 
 				cp= BLI_dynlib_find_symbol(pis->handle, "seqname");
-				if(cp) BLI_strncpy(cp, seqname, 21);
+				if(cp) BLI_strncpy(cp, seqname, SEQ_NAME_MAXSTR);
 			} else {
 				printf ("Plugin returned unrecognized version number\n");
 				return;
@@ -303,7 +303,10 @@
 		cp = BLI_dynlib_find_symbol(
 			seq->plugin->handle, "seqname");
 
-		if(cp) strncpy(cp, seq->name+2, 22);
+		/* XXX: it's crappy to limit copying buffer by it's lemgth,
+		 *      but assuming plugin stuff is using correct buffer size
+		 *      it should be fine */
+		if(cp) strncpy(cp, seq->name+2, sizeof(seq->name));
 
 		if (seq->plugin->current_private_data) {
 			*seq->plugin->current_private_data 

Modified: trunk/blender/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sequencer.c	2012-01-11 07:27:39 UTC (rev 43282)
+++ trunk/blender/source/blender/blenkernel/intern/sequencer.c	2012-01-11 08:51:06 UTC (rev 43283)
@@ -833,8 +833,8 @@
 
 typedef struct SeqUniqueInfo {
 	Sequence *seq;
-	char name_src[32];
-	char name_dest[32];
+	char name_src[SEQ_NAME_MAXSTR];

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list