Fix: Escape property name when keying

The property name can contain `"` which would cause keyframing to
fail. By escaping it those properties can now be keyframed.

E.g. property names like `"test"` now properly receive keys.

Pull Request: https://projects.blender.org/blender/blender/pulls/119922
This commit is contained in:
Christoph Lendenfeld
2024-04-02 16:24:59 +02:00
committed by Christoph Lendenfeld
parent 7400927ada
commit 8a1c2b172a
2 changed files with 6 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ set(INC
../../makesrna
../../sequencer
../../windowmanager
../../../../extern/fmtlib/include
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)

View File

@@ -9,6 +9,8 @@
#include <cstddef>
#include <cstdio>
#include <fmt/format.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
@@ -298,9 +300,9 @@ static blender::Vector<std::string> construct_rna_paths(PointerRNA *ptr)
if (insert_channel_flags & USER_ANIM_KEY_CHANNEL_CUSTOM_PROPERTIES) {
if (properties) {
LISTBASE_FOREACH (IDProperty *, prop, &properties->data.group) {
std::string name = prop->name;
std::string rna_path = "[\"" + name + "\"]";
paths.append(rna_path);
char name_escaped[MAX_IDPROP_NAME * 2];
BLI_str_escape(name_escaped, prop->name, sizeof(name_escaped));
paths.append(fmt::format("[\"{}\"]", name_escaped));
}
}
}