Fix #131748: Error with pasting pose on liboverride armature.
Either initial fix (9405bd25d6) was not fully correct (and properly
tested), or something else changed since then, but the handling of
liboverrides in copy/paste of poses would not be correct for local
overrides.
Instead of relying on generic `BKE_lib_id_make_local` to also work
for local liboverrides, add some more logic in `PartialWriteContext::make_local`
to properly handle local liboverrides when the override data needs to get
removed in the copy buffer blendfile.
NOTE: Not super-happy with how make local and removal of liboverrides
somewhat mix together currently. Will need to revisit once again that
whole process at some point.
This commit is contained in:
@@ -1817,7 +1817,18 @@ void PartialWriteContext::make_local(ID *ctx_id, const int make_local_flags)
|
||||
BKE_main_idmap_remove_id(this->bmain.id_map, ctx_id);
|
||||
BKE_main_idmap_remove_id(matching_uid_map_, ctx_id);
|
||||
|
||||
BKE_lib_id_make_local(&this->bmain, ctx_id, make_local_flags);
|
||||
if (ID_IS_LINKED(ctx_id)) {
|
||||
BKE_lib_id_make_local(&this->bmain, ctx_id, make_local_flags);
|
||||
}
|
||||
/* NOTE: Cannot rely only on `ID_IS_OVERRIDE_LIBRARY` here, as the reference pointer to the
|
||||
* linked data may have already been cleared out by dependency management in code above that
|
||||
* call. */
|
||||
else if ((ctx_id->override_library || ID_IS_OVERRIDE_LIBRARY(ctx_id)) &&
|
||||
(make_local_flags & LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR) != 0)
|
||||
|
||||
{
|
||||
BKE_lib_override_library_make_local(&this->bmain, ctx_id);
|
||||
}
|
||||
|
||||
this->preempt_session_uid(ctx_id, ctx_id_session_uid);
|
||||
BKE_main_idmap_insert_id(this->bmain.id_map, ctx_id);
|
||||
|
||||
@@ -3817,15 +3817,18 @@ void BKE_lib_override_library_delete(Main *bmain, ID *id_root)
|
||||
|
||||
void BKE_lib_override_library_make_local(Main *bmain, ID *id)
|
||||
{
|
||||
if (!ID_IS_OVERRIDE_LIBRARY(id)) {
|
||||
return;
|
||||
}
|
||||
if (ID_IS_OVERRIDE_LIBRARY_VIRTUAL(id)) {
|
||||
/* We should never directly 'make local' virtual overrides (aka shape keys). */
|
||||
BLI_assert_unreachable();
|
||||
id->flag &= ~ID_FLAG_EMBEDDED_DATA_LIB_OVERRIDE;
|
||||
return;
|
||||
}
|
||||
/* Cannot use `ID_IS_OVERRIDE_LIBRARY` here, as we may call this function on some already
|
||||
* partially processed liboverrides (e.g. from the #PartialWriteContext code), where the linked
|
||||
* reference pointer has already been set to null. */
|
||||
if (!id->override_library) {
|
||||
return;
|
||||
}
|
||||
|
||||
BKE_lib_override_library_free(&id->override_library, true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user