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.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
if (r_real_id != NULL) {
|
||||
*r_real_id = NULL;
|
||||
}
|
||||
|
||||
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 (path != NULL) {
|
||||
char *new_path = NULL;
|
||||
|
||||
*r_real = RNA_find_real_ID_and_path(bmain, id, &prefix);
|
||||
|
||||
if (*r_real) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user