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:
authorCampbell Barton <ideasman42@gmail.com>2015-11-30 14:38:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-12-01 02:31:10 +0300
commit9307202807e4ff52f2266b17597fa85ee6377293 (patch)
tree45f5f6b85b5854ed5ae2ad30dcfa3371eeee3749 /source
parentb7978e984b4885495d0966d0c8652ff43ddf9fc9 (diff)
RNA: de-duplciate rna-path create in tooltip code
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_regions.c29
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/intern/rna_access.c31
3 files changed, 34 insertions, 27 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 3a24625c36c..5fe6fd119aa 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -534,33 +534,18 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
if (but->rnapoin.id.data) {
/* this could get its own 'BUT_GET_...' type */
- PointerRNA *ptr = &but->rnapoin;
- PropertyRNA *prop = but->rnaprop;
- ID *id = ptr->id.data;
-
- char *id_path;
- char *data_path = NULL;
/* never fails */
- id_path = RNA_path_full_ID_py(id);
-
- if (ptr->data && prop) {
- data_path = RNA_path_from_ID_to_property(ptr, prop);
- }
+ char *id_path;
- if (data_path) {
- const char *data_delim = (data_path[0] == '[') ? "" : ".";
- BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]),
- "%s%s%s", /* no need to translate */
- id_path, data_delim, data_path);
- MEM_freeN(data_path);
+ if (but->rnaprop) {
+ id_path = RNA_path_full_property_py_ex(&but->rnapoin, but->rnaprop, but->rnaindex, true);
}
- else if (prop) {
- /* can't find the path. be explicit in our ignorance "..." */
- BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]),
- "%s ... %s", /* no need to translate */
- id_path, rna_prop.strinfo ? rna_prop.strinfo : RNA_property_identifier(prop));
+ else {
+ id_path = RNA_path_full_struct_py(&but->rnapoin);
}
+
+ BLI_strncat_utf8(data->lines[data->totline], id_path, sizeof(data->lines[0]));
MEM_freeN(id_path);
data->format[data->totline].style = UI_TIP_STYLE_MONO;
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 406bab011aa..480d34ae34e 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -973,6 +973,7 @@ char *RNA_path_resolve_from_type_to_property(
char *RNA_path_full_ID_py(struct ID *id);
char *RNA_path_full_struct_py(struct PointerRNA *ptr);
+char *RNA_path_full_property_py_ex(PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback);
char *RNA_path_full_property_py(struct PointerRNA *ptr, struct PropertyRNA *prop, int index);
char *RNA_path_struct_property_py(struct PointerRNA *ptr, struct PropertyRNA *prop, int index);
char *RNA_path_property_py(struct PointerRNA *ptr, struct PropertyRNA *prop, int index);
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 5e4ea749b22..ede5073483b 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -4719,11 +4719,12 @@ char *RNA_path_full_struct_py(struct PointerRNA *ptr)
* Get the ID.struct.property as a python representation, eg:
* bpy.data.foo["bar"].some_struct.some_prop[10]
*/
-char *RNA_path_full_property_py(PointerRNA *ptr, PropertyRNA *prop, int index)
+char *RNA_path_full_property_py_ex(PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback)
{
char *id_path;
const char *data_delim;
- char *data_path;
+ const char *data_path;
+ bool data_path_free;
char *ret;
@@ -4735,8 +4736,23 @@ char *RNA_path_full_property_py(PointerRNA *ptr, PropertyRNA *prop, int index)
id_path = RNA_path_full_ID_py(ptr->id.data);
data_path = RNA_path_from_ID_to_property(ptr, prop);
+ if (data_path) {
+ data_delim = (data_path[0] == '[') ? "" : ".";
+ data_path_free = true;
+ }
+ else {
+ if (use_fallback) {
+ /* fuzzy fallback. be explicit in our ignoranc. */
+ data_path = RNA_property_identifier(prop);
+ data_delim = " ... ";
+ }
+ else {
+ data_delim = ".";
+
+ }
+ data_path_free = false;
+ }
- data_delim = (data_path && data_path[0] == '[') ? "" : ".";
if ((index == -1) || (RNA_property_array_check(prop) == false)) {
ret = BLI_sprintfN("%s%s%s",
@@ -4747,13 +4763,18 @@ char *RNA_path_full_property_py(PointerRNA *ptr, PropertyRNA *prop, int index)
id_path, data_delim, data_path, index);
}
MEM_freeN(id_path);
- if (data_path) {
- MEM_freeN(data_path);
+ if (data_path_free) {
+ MEM_freeN((void *)data_path);
}
return ret;
}
+char *RNA_path_full_property_py(PointerRNA *ptr, PropertyRNA *prop, int index)
+{
+ return RNA_path_full_property_py_ex(ptr, prop, index, false);
+}
+
/**
* Get the struct.property as a python representation, eg:
* some_struct.some_prop[10]