diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-12-09 12:26:08 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-12-11 14:07:13 +0300 |
commit | 75fbd60b0658e1f7de4975417d752ce428fc3dc0 (patch) | |
tree | 8082853263d77bbc775727df1a78519264baaeb2 | |
parent | 48fe46943e03a0d96e7fe6ff4d5a7a070a779503 (diff) |
Walk all the overriding chain to try to find a template.
When one creates a new local static override from another linked
data-block already overriding a third one etc., walk the whole
inheritance chain up to the original ancestor to try to find an
overriding template, instead of only checking the immediate reference...
-rw-r--r-- | source/blender/blenkernel/intern/library_override.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c index 22896cff64a..26aeca0564d 100644 --- a/source/blender/blenkernel/intern/library_override.c +++ b/source/blender/blenkernel/intern/library_override.c @@ -66,16 +66,26 @@ IDOverrideStatic *BKE_override_static_init(ID *local_id, ID *reference_id) BLI_assert(reference_id == NULL || reference_id->lib != NULL); BLI_assert(local_id->override_static == NULL); - if (reference_id != NULL && reference_id->override_static != NULL && reference_id->override_static->reference == NULL) { - /* reference ID has an override template, use it! */ - BKE_override_static_copy(local_id, reference_id); + ID *ancestor_id; + for (ancestor_id = reference_id; + ancestor_id != NULL && ancestor_id->override_static != NULL && ancestor_id->override_static->reference != NULL; + ancestor_id = ancestor_id->override_static->reference); + + if (ancestor_id != NULL && ancestor_id->override_static != NULL) { + /* Original ID has a template, use it! */ + BKE_override_static_copy(local_id, ancestor_id); + if (local_id->override_static->reference != reference_id) { + id_us_min(local_id->override_static->reference); + local_id->override_static->reference = reference_id; + id_us_plus(local_id->override_static->reference); + } return local_id->override_static; } /* Else, generate new empty override. */ local_id->override_static = MEM_callocN(sizeof(*local_id->override_static), __func__); local_id->override_static->reference = reference_id; - id_us_plus(reference_id); + id_us_plus(local_id->override_static->reference); local_id->tag &= ~LIB_TAG_OVERRIDESTATIC_OK; /* TODO do we want to add tag or flag to referee to mark it as such? */ return local_id->override_static; |