1
1

Fix T73250: Override Library will always return to Object Mode on file opening.

Was an old known annoying issue, since the matching RNA property is
read-only we need a manual handling of this in override applying and
resyncing code.
This commit is contained in:
2022-05-19 09:05:24 +02:00
parent 5d0432a2ea
commit 2e06c223cc

View File

@@ -72,6 +72,21 @@ static void lib_override_library_property_clear(IDOverrideLibraryProperty *op);
static void lib_override_library_property_operation_clear(
IDOverrideLibraryPropertyOperation *opop);
/** Helper to preserve Pose mode on override objects.
* A bit annoying to have this special case, but not much to be done here currently, since the
* matching RNA property is read-only. */
BLI_INLINE void lib_override_object_posemode_transfer(ID *id_dst, ID *id_src)
{
if (GS(id_src->name) == ID_OB && GS(id_dst->name) == ID_OB) {
Object *ob_src = (Object *)id_src;
Object *ob_dst = (Object *)id_dst;
if (ob_src->type == OB_ARMATURE && (ob_src->mode & OB_MODE_POSE) != 0) {
ob_dst->restore_mode = ob_dst->mode;
ob_dst->mode |= OB_MODE_POSE;
}
}
}
/** Get override data for a given ID. Needed because of our beloved shape keys snowflake. */
BLI_INLINE IDOverrideLibrary *lib_override_get(Main *bmain, ID *id, ID **r_owner_id)
{
@@ -1703,6 +1718,8 @@ static bool lib_override_library_resync(Main *bmain,
id_override_old->tag |= LIB_TAG_NO_MAIN;
id_override_new->tag &= ~LIB_TAG_NO_MAIN;
lib_override_object_posemode_transfer(id_override_new, id_override_old);
if (ID_IS_OVERRIDE_LIBRARY_REAL(id_override_new)) {
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_override_old));
@@ -3423,6 +3440,8 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
local->override_library,
RNA_OVERRIDE_APPLY_FLAG_NOP);
lib_override_object_posemode_transfer(tmp_id, local);
/* This also transfers all pointers (memory) owned by local to tmp_id, and vice-versa.
* So when we'll free tmp_id, we'll actually free old, outdated data from local. */
lib_override_id_swap(bmain, local, tmp_id);