main sync #3

Merged
Patrick Busch merged 318 commits from blender/blender:main into main 2023-03-17 15:52:21 +01:00
4 changed files with 24 additions and 4 deletions
Showing only changes of commit f4c6ad5eb3 - Show all commits

View File

@ -64,6 +64,14 @@ void RNA_def_struct_register_funcs(StructRNA *srna,
const char *reg,
const char *unreg,
const char *instance);
/**
* Return an allocated string for the RNA data-path:
*
* - Double quotes must be used for string access, e.g: `collection["%s"]`.
* - Strings containing arbitrary characters must be escaped using #BLI_str_escape.
*
* Paths must be compatible with #RNA_path_resolve & related functions.
*/
void RNA_def_struct_path_func(StructRNA *srna, const char *path);
/**
* Only used in one case when we name the struct for the purpose of useful error messages.

View File

@ -64,7 +64,9 @@ int rna_AssetMetaData_editable(PointerRNA *ptr, const char **r_info)
static char *rna_AssetTag_path(const PointerRNA *ptr)
{
const AssetTag *asset_tag = ptr->data;
return BLI_sprintfN("asset_data.tags['%s']", asset_tag->name);
char asset_tag_name_esc[sizeof(asset_tag->name) * 2];
BLI_str_escape(asset_tag_name_esc, asset_tag->name, sizeof(asset_tag_name_esc));
return BLI_sprintfN("asset_data.tags[\"%s\"]", asset_tag_name_esc);
}
static int rna_AssetTag_editable(PointerRNA *ptr, const char **r_info)

View File

@ -136,7 +136,9 @@ const EnumPropertyItem rna_enum_attribute_curves_domain_items[] = {
static char *rna_Attribute_path(const PointerRNA *ptr)
{
const CustomDataLayer *layer = ptr->data;
return BLI_sprintfN("attributes['%s']", layer->name);
char layer_name_esc[sizeof(layer->name) * 2];
BLI_str_escape(layer_name_esc, layer->name, sizeof(layer_name_esc));
return BLI_sprintfN("attributes[\"%s\"]", layer_name_esc);
}
static StructRNA *srna_by_custom_data_layer_type(const eCustomDataType type)

View File

@ -1193,7 +1193,9 @@ static char *rna_ImageFormatSettings_path(const PointerRNA *ptr)
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == CMP_NODE_OUTPUT_FILE) {
if (&((NodeImageMultiFile *)node->storage)->format == imf) {
return BLI_sprintfN("nodes['%s'].format", node->name);
char node_name_esc[sizeof(node->name) * 2];
BLI_str_escape(node_name_esc, node->name, sizeof(node_name_esc));
return BLI_sprintfN("nodes[\"%s\"].format", node_name_esc);
}
else {
bNodeSocket *sock;
@ -1201,8 +1203,14 @@ static char *rna_ImageFormatSettings_path(const PointerRNA *ptr)
for (sock = node->inputs.first; sock; sock = sock->next) {
NodeImageMultiFileSocket *sockdata = sock->storage;
if (&sockdata->format == imf) {
char node_name_esc[sizeof(node->name) * 2];
BLI_str_escape(node_name_esc, node->name, sizeof(node_name_esc));
char socketdata_path_esc[sizeof(sockdata->path) * 2];
BLI_str_escape(socketdata_path_esc, sockdata->path, sizeof(socketdata_path_esc));
return BLI_sprintfN(
"nodes['%s'].file_slots['%s'].format", node->name, sockdata->path);
"nodes[\"%s\"].file_slots[\"%s\"].format", node_name_esc, socketdata_path_esc);
}
}
}