[Bf-blender-cvs] [9d6d413c7c5] blender2.8: RNA: check for duplicate manipulator names

Campbell Barton noreply at git.blender.org
Wed Aug 23 08:20:03 CEST 2017


Commit: 9d6d413c7c543463eea7874e7d5d4cf1e914325e
Author: Campbell Barton
Date:   Wed Aug 23 16:22:48 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB9d6d413c7c543463eea7874e7d5d4cf1e914325e

RNA: check for duplicate manipulator names

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

M	source/blender/makesrna/intern/rna_wm_manipulator.c

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

diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
index a0fdd76e4a3..b074433e3b5 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator.c
@@ -434,14 +434,6 @@ static StructRNA *rna_Manipulator_register(
 		return NULL;
 	}
 
-	{   /* allocate the idname */
-		const uint idname_len = strlen(temp_buffers.idname) + 1;
-		char *ch = MEM_mallocN(
-		        sizeof(char) * idname_len, __func__);
-		dummywt.idname = ch;
-		memcpy(ch, temp_buffers.idname, idname_len);
-	}
-
 	/* check if we have registered this manipulator type before, and remove it */
 	{
 		const wmManipulatorType *wt = WM_manipulatortype_find(dummywt.idname, true);
@@ -449,6 +441,17 @@ static StructRNA *rna_Manipulator_register(
 			rna_Manipulator_unregister(bmain, wt->ext.srna);
 		}
 	}
+	if (!RNA_struct_available_or_report(reports, identifier)) {
+		return NULL;
+	}
+
+	{   /* allocate the idname */
+		const uint idname_len = strlen(temp_buffers.idname) + 1;
+		char *ch = MEM_mallocN(
+		        sizeof(char) * idname_len, __func__);
+		dummywt.idname = ch;
+		memcpy(ch, temp_buffers.idname, idname_len);
+	}
 
 	/* create a new manipulator type */
 	dummywt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywt.idname, &RNA_Manipulator);
@@ -739,6 +742,17 @@ static StructRNA *rna_ManipulatorGroup_register(
 		return NULL;
 	}
 
+	/* check if we have registered this manipulatorgroup type before, and remove it */
+	{
+		wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(dummywgt.idname, true);
+		if (wgt && wgt->ext.srna) {
+			rna_ManipulatorGroup_unregister(bmain, wgt->ext.srna);
+		}
+	}
+	if (!RNA_struct_available_or_report(reports, identifier)) {
+		return NULL;
+	}
+
 	{   /* allocate the idname */
 		const uint idname_len = strlen(temp_buffers.idname) + 1;
 		const uint name_len = strlen(temp_buffers.name) + 1;
@@ -751,14 +765,6 @@ static StructRNA *rna_ManipulatorGroup_register(
 		dummywgt.name = ch;
 	}
 
-	/* check if we have registered this manipulatorgroup type before, and remove it */
-	{
-		wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(dummywgt.idname, true);
-		if (wgt && wgt->ext.srna) {
-			rna_ManipulatorGroup_unregister(bmain, wgt->ext.srna);
-		}
-	}
-
 	/* create a new manipulatorgroup type */
 	dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_ManipulatorGroup);
 	RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); /* manipulatorgroup properties are registered separately */



More information about the Bf-blender-cvs mailing list