[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60213] trunk/blender/source/blender: fix relating to bug [#36758],

Campbell Barton ideasman42 at gmail.com
Wed Sep 18 03:22:32 CEST 2013


Revision: 60213
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60213
Author:   campbellbarton
Date:     2013-09-18 01:22:28 +0000 (Wed, 18 Sep 2013)
Log Message:
-----------
fix relating to bug [#36758],
When printing operator reports, ommit unset properties.
This is needed because in some cases operators check if a value is set or not, so filling in default arguments may change behavior.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/intern/rna_access.c
    trunk/blender/source/blender/python/intern/bpy_rna.c
    trunk/blender/source/blender/windowmanager/intern/wm_event_system.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h	2013-09-18 00:28:23 UTC (rev 60212)
+++ trunk/blender/source/blender/makesrna/RNA_access.h	2013-09-18 01:22:28 UTC (rev 60213)
@@ -1035,15 +1035,15 @@
 /* python compatible string representation of this property, (must be freed!) */
 char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index, int max_prop_length);
 char *RNA_pointer_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop_ptr, PointerRNA *ptr_prop);
-char *RNA_pointer_as_string_keywords_ex(struct bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
-                                        const short skip_optional_value, const short all_args,
+char *RNA_pointer_as_string_keywords_ex(struct bContext *C, PointerRNA *ptr,
+                                        const bool skip_optional_value, const bool all_args,
                                         const int max_prop_length,
                                         PropertyRNA *iterprop);
-char *RNA_pointer_as_string_keywords(struct bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
-                                     const short skip_optional_value, const short all_args,
+char *RNA_pointer_as_string_keywords(struct bContext *C, PointerRNA *ptr,
+                                     const bool skip_optional_value, const bool all_args,
                                      const int max_prop_length);
-char *RNA_function_as_string_keywords(struct bContext *C, FunctionRNA *func, PointerRNA *ptr_default,
-                                      const short as_function, const short all_args,
+char *RNA_function_as_string_keywords(struct bContext *C, FunctionRNA *func,
+                                      const bool as_function, const bool all_args,
                                       const int max_prop_length);
 
 /* Function */

Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c	2013-09-18 00:28:23 UTC (rev 60212)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c	2013-09-18 01:22:28 UTC (rev 60213)
@@ -4175,7 +4175,7 @@
 {
 	DynStr *dynstr = BLI_dynstr_new();
 	char *path;
-	short first = TRUE;
+	bool is_first = true;
 
 	int tot = 0;
 	IDP_Chain *link = child_link;
@@ -4194,13 +4194,13 @@
 	for (link = link_prev; link; link = link->up) {
 		/* pass */
 		if (link->index >= 0) {
-			BLI_dynstr_appendf(dynstr, first ? "%s[%d]" : ".%s[%d]", link->name, link->index);
+			BLI_dynstr_appendf(dynstr, is_first ? "%s[%d]" : ".%s[%d]", link->name, link->index);
 		}
 		else {
-			BLI_dynstr_appendf(dynstr, first ? "%s" : ".%s", link->name);
+			BLI_dynstr_appendf(dynstr, is_first ? "%s" : ".%s", link->name);
 		}
 
-		first = FALSE;
+		is_first = false;
 	}
 
 	path = BLI_dynstr_get_cstring(dynstr);
@@ -5041,9 +5041,9 @@
 	}
 }
 
-/* context and ptr_default can be NULL */
-char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
-                                        const short as_function, const short all_args,
+/* context can be NULL */
+char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr,
+                                        const bool as_function, const bool all_args,
                                         const int max_prop_length,
                                         PropertyRNA *iterprop)
 {
@@ -5053,13 +5053,9 @@
 
 	DynStr *dynstr = BLI_dynstr_new();
 	char *cstring, *buf;
-	int first_iter = TRUE, ok = TRUE;
+	bool first_iter = true;
 	int flag;
 
-	/* only to get the orginal props for comparisons */
-	PropertyRNA *prop_default;
-	char *buf_default;
-
 	RNA_PROP_BEGIN (ptr, propptr, iterprop)
 	{
 		prop = propptr.data;
@@ -5079,45 +5075,37 @@
 		if (as_function && (flag & PROP_REQUIRED)) {
 			/* required args don't have useful defaults */
 			BLI_dynstr_appendf(dynstr, first_iter ? "%s" : ", %s", arg_name);
-			first_iter = FALSE;
+			first_iter = false;
 		}
 		else {
-			if (as_function && RNA_property_type(prop) == PROP_POINTER) {
-				/* don't expand pointers for functions */
-				if (flag & PROP_NEVER_NULL) {
-					/* we cant really do the right thing here. arg=arg?, hrmf! */
-					buf = BLI_strdup(arg_name);
-				}
-				else {
-					buf = BLI_strdup("None");
-				}
+			bool ok = true;
+
+			if (all_args == true) {
+				/* pass */
 			}
-			else {
-				buf = RNA_property_as_string(C, ptr, prop, -1, max_prop_length);
+			else if (RNA_struct_idprops_check(ptr->type)) {
+				ok = RNA_property_is_set(ptr, prop);
 			}
 
-			ok = TRUE;
-
-			if (all_args == FALSE && ptr_default) {
-				/* not verbose, so only add in attributes that use non-default values
-				 * slow but good for tooltips */
-				prop_default = RNA_struct_find_property(ptr_default, arg_name);
-
-				if (prop_default) {
-					buf_default = RNA_property_as_string(C, ptr_default, prop_default, -1, max_prop_length);
-
-					if (strcmp(buf, buf_default) == 0)
-						ok = FALSE;  /* values match, don't bother printing */
-
-					MEM_freeN(buf_default);
-				}
-			}
 			if (ok) {
+				if (as_function && RNA_property_type(prop) == PROP_POINTER) {
+					/* don't expand pointers for functions */
+					if (flag & PROP_NEVER_NULL) {
+						/* we cant really do the right thing here. arg=arg?, hrmf! */
+						buf = BLI_strdup(arg_name);
+					}
+					else {
+						buf = BLI_strdup("None");
+					}
+				}
+				else {
+					buf = RNA_property_as_string(C, ptr, prop, -1, max_prop_length);
+				}
+
 				BLI_dynstr_appendf(dynstr, first_iter ? "%s=%s" : ", %s=%s", arg_name, buf);
-				first_iter = FALSE;
+				first_iter = false;
+				MEM_freeN(buf);
 			}
-
-			MEM_freeN(buf);
 		}
 	}
 	RNA_PROP_END;
@@ -5127,20 +5115,20 @@
 	return cstring;
 }
 
-char *RNA_pointer_as_string_keywords(bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
-                                     const short as_function, const short all_args,
+char *RNA_pointer_as_string_keywords(bContext *C, PointerRNA *ptr,
+                                     const bool as_function, const bool all_args,
                                      const int max_prop_length)
 {
 	PropertyRNA *iterprop;
 
 	iterprop = RNA_struct_iterator_property(ptr->type);
 
-	return RNA_pointer_as_string_keywords_ex(C, ptr, ptr_default, as_function, all_args,
+	return RNA_pointer_as_string_keywords_ex(C, ptr, as_function, all_args,
 	                                         max_prop_length, iterprop);
 }
 
-char *RNA_function_as_string_keywords(bContext *C, FunctionRNA *func, PointerRNA *ptr_default,
-                                      const short as_function, const short all_args,
+char *RNA_function_as_string_keywords(bContext *C, FunctionRNA *func,
+                                      const bool as_function, const bool all_args,
                                       const int max_prop_length)
 {
 	PointerRNA funcptr;
@@ -5152,7 +5140,7 @@
 
 	RNA_struct_iterator_property(funcptr.type);
 
-	return RNA_pointer_as_string_keywords_ex(C, &funcptr, ptr_default, as_function, all_args,
+	return RNA_pointer_as_string_keywords_ex(C, &funcptr, as_function, all_args,
 	                                         max_prop_length, iterprop);
 }
 
@@ -5263,11 +5251,11 @@
 
 					RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
 					if (item) {
-						short is_first = TRUE;
+						bool is_first = false;
 						for (; item->identifier; item++) {
 							if (item->identifier[0] && item->value & val) {
 								BLI_dynstr_appendf(dynstr, is_first ? "'%s'" : ", '%s'", item->identifier);
-								is_first = FALSE;
+								is_first = false;
 							}
 						}
 

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c	2013-09-18 00:28:23 UTC (rev 60212)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c	2013-09-18 01:22:28 UTC (rev 60213)
@@ -5333,7 +5333,7 @@
 	PyObject *ret;
 	char *args;
 
-	args = RNA_function_as_string_keywords(NULL, self->func, NULL, true, true, INT_MAX);
+	args = RNA_function_as_string_keywords(NULL, self->func, true, true, INT_MAX);
 
 	ret = PyUnicode_FromFormat("%.200s.%.200s(%.200s)\n%s",
 	                           RNA_struct_identifier(self->ptr.type),

Modified: trunk/blender/source/blender/windowmanager/intern/wm_event_system.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_event_system.c	2013-09-18 00:28:23 UTC (rev 60212)
+++ trunk/blender/source/blender/windowmanager/intern/wm_event_system.c	2013-09-18 01:22:28 UTC (rev 60213)
@@ -491,7 +491,7 @@
 static void wm_operator_print(bContext *C, wmOperator *op)
 {
 	/* context is needed for enum function */
-	char *buf = WM_operator_pystring(C, op->type, op->ptr, 1);
+	char *buf = WM_operator_pystring(C, op->type, op->ptr, false);
 	printf("%s\n", buf);
 	MEM_freeN(buf);
 }
@@ -626,7 +626,7 @@
 		if (op->type->flag & OPTYPE_REGISTER) {
 			if (G.background == 0) { /* ends up printing these in the terminal, gets annoying */
 				/* Report the python string representation of the operator */
-				char *buf = WM_operator_pystring(C, op->type, op->ptr, 1);
+				char *buf = WM_operator_pystring(C, op->type, op->ptr, false);
 				BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf);
 				MEM_freeN(buf);
 			}
@@ -660,7 +660,7 @@
 	
 	if (repeat == 0) {
 		if (G.debug & G_DEBUG_WM) {
-			char *buf = WM_operator_pystring(C, op->type, op->ptr, 1);
+			char *buf = WM_operator_pystring(C, op->type, op->ptr, false);
 			BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf);
 			MEM_freeN(buf);
 		}

Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2013-09-18 00:28:23 UTC (rev 60212)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2013-09-18 01:22:28 UTC (rev 60213)
@@ -542,22 +542,20 @@
 	/* only to get the orginal props for comparisons */
 	PointerRNA opptr_default;
 
-	if (all_args == 0 || opptr == NULL) {
+	if (opptr == NULL) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list