[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55797] trunk/blender/source/blender: Fix #34862: some operators like mesh separate or object clear parent were not

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Apr 5 02:53:38 CEST 2013


Revision: 55797
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55797
Author:   blendix
Date:     2013-04-05 00:53:37 +0000 (Fri, 05 Apr 2013)
Log Message:
-----------
Fix #34862: some operators like mesh separate or object clear parent were not
showing shortcuts in menus, now it shows them in the submenu.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/object/object_relations.c
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/intern/rna_access.c
    trunk/blender/source/blender/windowmanager/intern/wm_keymap.c

Modified: trunk/blender/source/blender/editors/object/object_relations.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_relations.c	2013-04-05 00:33:59 UTC (rev 55796)
+++ trunk/blender/source/blender/editors/object/object_relations.c	2013-04-05 00:53:37 UTC (rev 55797)
@@ -549,7 +549,7 @@
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 	
-	ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", "");
+	ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_parent_types, CLEAR_PARENT_ALL, "Type", "");
 }
 
 /* ******************** Make Parent Operator *********************** */

Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h	2013-04-05 00:33:59 UTC (rev 55796)
+++ trunk/blender/source/blender/makesrna/RNA_access.h	2013-04-05 00:53:37 UTC (rev 55797)
@@ -1077,10 +1077,11 @@
 #endif
 ;
 
-/* Equals test (skips pointers and collections) */
+/* Equals test (skips pointers and collections)
+ * is_strict false assumes uninitialized properties are equal */
 
-int RNA_property_equals(struct PointerRNA *a, struct PointerRNA *b, struct PropertyRNA *prop);
-int RNA_struct_equals(struct PointerRNA *a, struct PointerRNA *b);
+bool RNA_property_equals(struct PointerRNA *a, struct PointerRNA *b, struct PropertyRNA *prop, bool is_strict);
+bool RNA_struct_equals(struct PointerRNA *a, struct PointerRNA *b, bool is_strict);
 
 #ifdef __cplusplus
 }

Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c	2013-04-05 00:33:59 UTC (rev 55796)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c	2013-04-05 00:53:37 UTC (rev 55797)
@@ -6179,14 +6179,19 @@
 #endif
 }
 
-int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop)
+bool RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop, bool is_strict)
 {
+	/* if not strict, uninitialized properties are assumed to match */
+	if (!is_strict)
+		if (!(RNA_property_is_set(a, prop) && RNA_property_is_set(b, prop)))
+			return true;
+
 	/* get the length of the array to work with */
 	int len = RNA_property_array_length(a, prop);
 	int fromlen = RNA_property_array_length(b, prop);
 
 	if (len != fromlen)
-		return 0;
+		return false;
 
 	/* get and set the default values as appropriate for the various types */
 	switch (RNA_property_type(prop)) {
@@ -6195,7 +6200,7 @@
 			if (len) {
 				int fixed_a[16], fixed_b[16];
 				int *array_a, *array_b;
-				int equals;
+				bool equals;
 
 				array_a = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals") : fixed_a;
 				array_b = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals") : fixed_b;
@@ -6221,7 +6226,7 @@
 			if (len) {
 				int fixed_a[16], fixed_b[16];
 				int *array_a, *array_b;
-				int equals;
+				bool equals;
 
 				array_a = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals"): fixed_a;
 				array_b = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals"): fixed_b;
@@ -6247,7 +6252,7 @@
 			if (len) {
 				float fixed_a[16], fixed_b[16];
 				float *array_a, *array_b;
-				int equals;
+				bool equals;
 
 				array_a = (len > 16) ? MEM_callocN(sizeof(float) * len, "RNA equals") : fixed_a;
 				array_b = (len > 16) ? MEM_callocN(sizeof(float) * len, "RNA equals") : fixed_b;
@@ -6280,7 +6285,7 @@
 			int len_a, len_b;
 			char *value_a = RNA_property_string_get_alloc(a, prop, fixed_a, sizeof(fixed_a), &len_a);
 			char *value_b = RNA_property_string_get_alloc(b, prop, fixed_b, sizeof(fixed_b), &len_b);
-			int equals = strcmp(value_a, value_b) == 0;
+			bool equals = strcmp(value_a, value_b) == 0;
 
 			if (value_a != fixed_a) MEM_freeN(value_a);
 			if (value_b != fixed_b) MEM_freeN(value_b);
@@ -6292,22 +6297,22 @@
 			break;
 	}
 
-	return 1;
+	return true;
 }
 
-int RNA_struct_equals(PointerRNA *a, PointerRNA *b)
+bool RNA_struct_equals(PointerRNA *a, PointerRNA *b, bool is_strict)
 {
 	CollectionPropertyIterator iter;
 //	CollectionPropertyRNA *citerprop;  /* UNUSED */
 	PropertyRNA *iterprop;
-	int equals = 1;
+	bool equals = true;
 
 	if (a == NULL && b == NULL)
-		return 1;
+		return true;
 	else if (a == NULL || b == NULL)
-		return 0;
+		return false;
 	else if (a->type != b->type)
-		return 0;
+		return false;
 
 	iterprop = RNA_struct_iterator_property(a->type);
 //	citerprop = (CollectionPropertyRNA *)rna_ensure_property(iterprop);  /* UNUSED */
@@ -6316,8 +6321,8 @@
 	for (; iter.valid; RNA_property_collection_next(&iter)) {
 		PropertyRNA *prop = iter.ptr.data;
 
-		if (!RNA_property_equals(a, b, prop)) {
-			equals = 0;
+		if (!RNA_property_equals(a, b, prop, is_strict)) {
+			equals = false;
 			break;
 		}
 	}

Modified: trunk/blender/source/blender/windowmanager/intern/wm_keymap.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_keymap.c	2013-04-05 00:33:59 UTC (rev 55796)
+++ trunk/blender/source/blender/windowmanager/intern/wm_keymap.c	2013-04-05 00:53:37 UTC (rev 55797)
@@ -101,7 +101,7 @@
 	if (strcmp(a->idname, b->idname) != 0)
 		return 0;
 	
-	if (!RNA_struct_equals(a->ptr, b->ptr))
+	if (!RNA_struct_equals(a->ptr, b->ptr, true))
 		return 0;
 	
 	if ((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE))
@@ -874,9 +874,14 @@
 						}
 #endif
 
-						if (kmi->ptr && IDP_EqualsProperties_ex(properties, kmi->ptr->data, is_strict)) {
-							if (keymap_r) *keymap_r = keymap;
-							return kmi;
+						if (kmi->ptr) {
+							PointerRNA properties_ptr;
+							RNA_pointer_create(NULL, kmi->ptr->type, properties, &properties_ptr);
+
+							if (RNA_struct_equals(&properties_ptr, kmi->ptr, is_strict)) {
+								if (keymap_r) *keymap_r = keymap;
+								return kmi;
+							}
 						}
 					}
 					else {
@@ -958,7 +963,12 @@
 
 			RNA_pointer_create(NULL, ot->srna, properties_default, &opptr);
 
-			if (WM_operator_properties_default(&opptr, true)) {
+			if (WM_operator_properties_default(&opptr, true) ||
+			    (ot->prop && RNA_property_is_set(&opptr, ot->prop))) {
+				/* for operator that has enum menu, unset it so it always matches */
+				if (ot->prop)
+					RNA_property_unset(&opptr, ot->prop);
+
 				found = wm_keymap_item_find_props(C, opname, opcontext, properties_default, 0, hotkey, keymap_r);
 			}
 




More information about the Bf-blender-cvs mailing list