Fix #107127: Context property driver to view layer does not work

The resolution of the driver value RNA path was using the wrong
property (it was forced to be referenced relative to the ID).

Pull Request: https://projects.blender.org/blender/blender/pulls/107129
This commit is contained in:
Sergey Sharybin
2023-04-19 15:32:37 +02:00
committed by Sergey Sharybin
parent 5ab48a53e4
commit 91a29c9b9a
3 changed files with 17 additions and 1 deletions

View File

@@ -84,6 +84,19 @@ RNAPathKey::RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop, RNAPoin
{
}
RNAPathKey::RNAPathKey(const PointerRNA &target_prop,
const char *rna_path_from_target_prop,
const RNAPointerSource source)
: id(target_prop.owner_id), source(source)
{
/* Try to resolve path. */
int index;
if (!RNA_path_resolve_full(&target_prop, rna_path_from_target_prop, &ptr, &prop, &index)) {
ptr = PointerRNA_NULL;
prop = nullptr;
}
}
string RNAPathKey::identifier() const
{
const char *id_name = (id) ? id->name : "<No ID>";

View File

@@ -188,6 +188,9 @@ struct PersistentOperationKey : public OperationKey {
struct RNAPathKey {
RNAPathKey(ID *id, const char *path, RNAPointerSource source);
RNAPathKey(const PointerRNA &target_prop,
const char *rna_path_from_target_prop,
RNAPointerSource source);
RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop, RNAPointerSource source);
string identifier() const;

View File

@@ -1807,7 +1807,7 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
add_relation(target_key, driver_key, "Target -> Driver");
}
else if (dtar->rna_path != nullptr && dtar->rna_path[0] != '\0') {
RNAPathKey variable_exit_key(target_id, dtar->rna_path, RNAPointerSource::EXIT);
RNAPathKey variable_exit_key(target_prop, dtar->rna_path, RNAPointerSource::EXIT);
if (RNA_pointer_is_null(&variable_exit_key.ptr)) {
continue;
}