[Bf-blender-cvs] [5759e33] master: Driver Variable Name Validation: Added missing check for zero-length (i.e. "blank") names

Joshua Leung noreply at git.blender.org
Sat Mar 26 06:02:44 CET 2016


Commit: 5759e335c3462b9d705b68be18d621364af18688
Author: Joshua Leung
Date:   Sat Mar 26 18:01:02 2016 +1300
Branches: master
https://developer.blender.org/rB5759e335c3462b9d705b68be18d621364af18688

Driver Variable Name Validation: Added missing check for zero-length (i.e. "blank") names

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

M	source/blender/blenkernel/intern/fcurve.c
M	source/blender/editors/space_graph/graph_buttons.c
M	source/blender/makesdna/DNA_anim_types.h

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

diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 52bece6..845229e 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1612,6 +1612,11 @@ void driver_variable_name_validate(DriverVar *dvar)
 	/* clear all invalid-name flags */
 	dvar->flag &= ~DVAR_ALL_INVALID_FLAGS;
 	
+	/* 0) Zero-length identifiers are not allowed */
+	if (dvar->name[0] == '\0') {
+		dvar->flag |= DVAR_FLAG_INVALID_EMPTY;
+	}
+	
 	/* 1) Must start with a letter */
 	/* XXX: We assume that valid unicode letters in other languages are ok too, hence the blacklisting */
 	if (ELEM(dvar->name[0], '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')) {
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 858baf6..f5057fd 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -527,6 +527,9 @@ static void driver_dvar_invalid_name_query_cb(bContext *C, void *dvar_v, void *U
 	
 	DriverVar *dvar = (DriverVar *)dvar_v;
 	
+	if (dvar->flag & DVAR_FLAG_INVALID_EMPTY) {
+		uiItemL(layout, "It cannot be left blank", ICON_ERROR);
+	}
 	if (dvar->flag & DVAR_FLAG_INVALID_START_NUM) {
 		uiItemL(layout, "It cannot start with a number", ICON_ERROR);
 	}
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index c8ba61d..55998ba 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -376,6 +376,8 @@ typedef enum eDriverVar_Flags {
 	DVAR_FLAG_INVALID_HAS_SPECIAL = (1 << 6),
 	/* name is a reserved keyword */
 	DVAR_FLAG_INVALID_PY_KEYWORD  = (1 << 7),
+	/* name is zero-length */
+	DVAR_FLAG_INVALID_EMPTY       = (1 << 8),
 } eDriverVar_Flags;
 
 /* All invalid dvar name flags */
@@ -386,7 +388,8 @@ typedef enum eDriverVar_Flags {
 	DVAR_FLAG_INVALID_HAS_SPACE |  \
 	DVAR_FLAG_INVALID_HAS_DOT |    \
 	DVAR_FLAG_INVALID_HAS_SPECIAL |  \
-	DVAR_FLAG_INVALID_PY_KEYWORD  \
+	DVAR_FLAG_INVALID_PY_KEYWORD  | \
+	DVAR_FLAG_INVALID_EMPTY  \
 )
 
 /* --- */




More information about the Bf-blender-cvs mailing list