Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-15 18:37:01 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-15 18:37:01 +0400
commit71775dc2a49d8ec20d31544f2fccf69729a8cd39 (patch)
tree39e17f1cb9a84516647dfc08714d1e304494bfb7 /source
parentbea14e8aaa518313a5ca851a0302db5649e6328b (diff)
Fix another cases where painting long brush strokes with small radius was slowed
down, this time by the operator properties getting converted to a string for display in the info window. With 1000+ stroke points this can get slow, and takes up too much space anyway, so now it's (somewhat arbitrarily) limited to printing only 10 points.
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesrna/RNA_access.h9
-rw-r--r--source/blender/makesrna/intern/rna_access.c29
-rw-r--r--source/blender/python/intern/bpy_rna.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c8
4 files changed, 29 insertions, 19 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 45613f2083f..9aeb1166aa6 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1031,15 +1031,18 @@ bool RNA_property_is_unlink(PropertyRNA *prop);
void RNA_struct_property_unset(PointerRNA *ptr, const char *identifier);
/* python compatible string representation of this property, (must be freed!) */
-char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index);
+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,
+ 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);
+ const short skip_optional_value, const short 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);
+ const short as_function, const short all_args,
+ const int max_prop_length);
/* Function */
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index beab5011f2e..32aeaebee58 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -4983,7 +4983,7 @@ static char *rna_pointer_as_string__idprop(bContext *C, PointerRNA *ptr)
BLI_dynstr_append(dynstr, ", ");
first_time = 0;
- cstring = RNA_property_as_string(C, ptr, prop, -1);
+ cstring = RNA_property_as_string(C, ptr, prop, -1, INT_MAX);
BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring);
MEM_freeN(cstring);
}
@@ -5023,6 +5023,7 @@ char *RNA_pointer_as_string(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *p
/* 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,
+ const int max_prop_length,
PropertyRNA *iterprop)
{
const char *arg_name = NULL;
@@ -5071,7 +5072,7 @@ char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr, PointerRNA
}
}
else {
- buf = RNA_property_as_string(C, ptr, prop, -1);
+ buf = RNA_property_as_string(C, ptr, prop, -1, max_prop_length);
}
ok = TRUE;
@@ -5082,7 +5083,7 @@ char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr, PointerRNA
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);
+ 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 */
@@ -5106,18 +5107,20 @@ char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr, PointerRNA
}
char *RNA_pointer_as_string_keywords(bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
- const short as_function, const short all_args)
+ const short as_function, const short 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,
- iterprop);
+ 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)
+ const short as_function, const short all_args,
+ const int max_prop_length)
{
PointerRNA funcptr;
PropertyRNA *iterprop;
@@ -5129,7 +5132,7 @@ char *RNA_function_as_string_keywords(bContext *C, FunctionRNA *func, PointerRNA
RNA_struct_iterator_property(funcptr.type);
return RNA_pointer_as_string_keywords_ex(C, &funcptr, ptr_default, as_function, all_args,
- iterprop);
+ max_prop_length, iterprop);
}
static const char *bool_as_py_string(const int var)
@@ -5137,7 +5140,7 @@ static const char *bool_as_py_string(const int var)
return var ? "True" : "False";
}
-char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index)
+char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index, int max_prop_length)
{
int type = RNA_property_type(prop);
int len = RNA_property_array_length(ptr, prop);
@@ -5277,18 +5280,18 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, in
}
case PROP_COLLECTION:
{
- int first_time = 1;
+ int i = 0;
CollectionPropertyIterator collect_iter;
BLI_dynstr_append(dynstr, "[");
- for (RNA_property_collection_begin(ptr, prop, &collect_iter); collect_iter.valid;
- RNA_property_collection_next(&collect_iter))
+ for (RNA_property_collection_begin(ptr, prop, &collect_iter);
+ (i < max_prop_length) && collect_iter.valid;
+ RNA_property_collection_next(&collect_iter), i++)
{
PointerRNA itemptr = collect_iter.ptr;
- if (first_time == 0)
+ if (i != 0)
BLI_dynstr_append(dynstr, ", ");
- first_time = 0;
/* now get every prop of the collection */
cstring = RNA_pointer_as_string(C, ptr, prop, &itemptr);
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index a0b2cd639bb..53340437e07 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -5318,7 +5318,7 @@ static PyObject *pyrna_func_doc_get(BPy_FunctionRNA *self, void *UNUSED(closure)
PyObject *ret;
char *args;
- args = RNA_function_as_string_keywords(NULL, self->func, NULL, true, true);
+ args = RNA_function_as_string_keywords(NULL, self->func, NULL, true, true, INT_MAX);
ret = PyUnicode_FromFormat("%.200s.%.200s(%.200s)\n%s",
RNA_struct_identifier(self->ptr.type),
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index c204554cc6c..4dce99dd017 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -541,6 +541,9 @@ char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, i
char *cstring;
char *cstring_args;
+ /* arbitrary, but can get huge string with stroke painting otherwise */
+ int max_prop_length = 10;
+
/* only to get the orginal props for comparisons */
PointerRNA opptr_default;
@@ -554,7 +557,8 @@ char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, i
WM_operator_py_idname(idname_py, ot->idname);
BLI_dynstr_appendf(dynstr, "bpy.ops.%s(", idname_py);
- cstring_args = RNA_pointer_as_string_keywords(C, opptr, &opptr_default, FALSE, all_args);
+ cstring_args = RNA_pointer_as_string_keywords(C, opptr, &opptr_default, FALSE,
+ all_args, max_prop_length);
BLI_dynstr_append(dynstr, cstring_args);
MEM_freeN(cstring_args);
@@ -737,7 +741,7 @@ char *WM_prop_pystring_assign(bContext *C, PointerRNA *ptr, PropertyRNA *prop, i
return NULL;
}
- rhs = RNA_property_as_string(C, ptr, prop, index);
+ rhs = RNA_property_as_string(C, ptr, prop, index, INT_MAX);
if (!rhs) {
MEM_freeN(lhs);
return NULL;