[Bf-blender-cvs] [6f1fa7aa256] master: Fix/enhance new RNA path from real ID helpers.

Bastien Montagne noreply at git.blender.org
Mon Sep 2 18:49:23 CEST 2019


Commit: 6f1fa7aa256d2acc4bc91ff459c369db55ff8a02
Author: Bastien Montagne
Date:   Mon Sep 2 18:33:55 2019 +0200
Branches: master
https://developer.blender.org/rB6f1fa7aa256d2acc4bc91ff459c369db55ff8a02

Fix/enhance new RNA path from real ID helpers.

Main issue was that `rna_prepend_real_ID_path()` would return
nothing in case given path was NULL, when it should actually return the
`prefix` computed by `RNA_find_real_ID_and_path()` in that case...

Also make return `real_id` pointer optionnal, no reasons to make it
mandatory here. And some general naming fixes.

===================================================================

M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_access.c

===================================================================

diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index c1199ac94b6..f9f05348c5c 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1168,7 +1168,7 @@ char *RNA_path_from_real_ID_to_property_index(struct Main *bmain,
                                               PropertyRNA *prop,
                                               int array_dim,
                                               int index,
-                                              struct ID **r_real);
+                                              struct ID **r_real_id);
 
 char *RNA_path_resolve_from_type_to_property(struct PointerRNA *ptr,
                                              struct PropertyRNA *prop,
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 531c2ef2003..61634a84d41 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -5794,15 +5794,23 @@ ID *RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path)
   }
 }
 
-static char *rna_prepend_real_ID_path(Main *bmain, ID *id, char *path, ID **r_real)
+static char *rna_prepend_real_ID_path(Main *bmain, ID *id, char *path, ID **r_real_id)
 {
-  if (path) {
-    const char *prefix;
-    char *new_path = NULL;
+  if (r_real_id != NULL) {
+    *r_real_id = NULL;
+  }
 
-    *r_real = RNA_find_real_ID_and_path(bmain, id, &prefix);
+  const char *prefix;
+  ID *real_id = RNA_find_real_ID_and_path(bmain, id, &prefix);
+
+  if (r_real_id != NULL) {
+    *r_real_id = real_id;
+  }
 
-    if (*r_real) {
+  if (path != NULL) {
+    char *new_path = NULL;
+
+    if (real_id) {
       if (prefix[0]) {
         new_path = BLI_sprintfN("%s%s%s", prefix, path[0] == '[' ? "" : ".", path);
       }
@@ -5815,7 +5823,7 @@ static char *rna_prepend_real_ID_path(Main *bmain, ID *id, char *path, ID **r_re
     return new_path;
   }
   else {
-    return NULL;
+    return prefix[0] != '\0' ? BLI_strdup(prefix) : NULL;
   }
 }
 
@@ -5975,11 +5983,11 @@ char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop)
 }
 
 char *RNA_path_from_real_ID_to_property_index(
-    Main *bmain, PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index, ID **r_real)
+    Main *bmain, PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index, ID **r_real_id)
 {
   char *path = RNA_path_from_ID_to_property_index(ptr, prop, index_dim, index);
 
-  return rna_prepend_real_ID_path(bmain, ptr->owner_id, path, r_real);
+  return rna_prepend_real_ID_path(bmain, ptr->owner_id, path, r_real_id);
 }
 
 /**



More information about the Bf-blender-cvs mailing list