diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-09-06 16:26:10 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-09-06 22:05:20 +0300 |
commit | 9ecbd67dfb672cd13f021c82d83aeb7ae8a8cf10 (patch) | |
tree | 9edad541160077d63cd77fe9c0210d29bebad6f3 /source/blender/python | |
parent | b0b24b77ffc3e34b3aef24ff658826a8aeca7782 (diff) |
Python API: implement an Operator callback for dynamic description.
Blender UI Layout API allows supplying parameters to operators via
button definitions. If an operator behavior strongly depends on its
parameters, it may be difficult to write a tooltip that covers all
of its operation modes. Thus it is useful to provide a way for the
operator to produce different descriptions based on the input info.
Reviewers: campbellbarton
Differential Revision: https://developer.blender.org/D5709
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 12005b92388..c5424ca6ffb 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1768,7 +1768,12 @@ static int pyrna_py_to_prop( if (value == Py_None) { if ((RNA_property_flag(prop) & PROP_NEVER_NULL) == 0) { if (data) { - *((char **)data) = (char *)NULL; + if (RNA_property_flag(prop) & PROP_THICK_WRAP) { + *(char *)data = 0; + } + else { + *((char **)data) = (char *)NULL; + } } else { RNA_property_string_set(ptr, prop, NULL); @@ -1813,7 +1818,12 @@ static int pyrna_py_to_prop( } else { if (data) { - *((char **)data) = (char *)param; + if (RNA_property_flag(prop) & PROP_THICK_WRAP) { + BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop)); + } + else { + *((char **)data) = (char *)param; + } } else { RNA_property_string_set_bytes(ptr, prop, param, PyBytes_Size(value)); @@ -1862,7 +1872,12 @@ static int pyrna_py_to_prop( /* XXX, this is suspect, but needed for function calls, * need to see if there's a better way. */ if (data) { - *((char **)data) = (char *)param; + if (RNA_property_flag(prop) & PROP_THICK_WRAP) { + BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop)); + } + else { + *((char **)data) = (char *)param; + } } else { RNA_property_string_set(ptr, prop, param); |