LibOverride: Fix crash in ShapeKeys when making a mesh override local.

Weird 'embedded for overrides' flag of embedded IDs (including ShapeKeys
in override context) was not properly cleaned up when making an override
fully local.

Reported by studio, thanks.

@jbakker should be backported to 2.93LTS if possible.
This commit is contained in:
Bastien Montagne 2021-06-28 17:00:08 +02:00
parent e8d75b957f
commit 37458798fa
Notes: blender-bot 2023-02-14 11:01:33 +01:00
Referenced by commit 11be9edae2, Fix missing proper 'make local' call for liboverrides from outliner.
Referenced by issue #88449: Blender LTS: Maintenance Task 2.93
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93
Referenced by issue #92793, File - > Append crashes every time on 2.93.6 (ARM)
4 changed files with 32 additions and 3 deletions

View File

@ -99,6 +99,8 @@ void BKE_lib_override_library_main_resync(struct Main *bmain,
void BKE_lib_override_library_delete(struct Main *bmain, struct ID *id_root);
void BKE_lib_override_library_make_local(struct ID *id);
struct IDOverrideLibraryProperty *BKE_lib_override_library_property_find(
struct IDOverrideLibrary *override, const char *rna_path);
struct IDOverrideLibraryProperty *BKE_lib_override_library_property_get(

View File

@ -1941,13 +1941,13 @@ void BKE_library_make_local(Main *bmain,
ntree->tag &= ~LIB_TAG_DOIT;
}
if (id->lib == NULL) {
if (!ID_IS_LINKED(id->lib)) {
id->tag &= ~(LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW);
id->flag &= ~LIB_INDIRECT_WEAK_LINK;
if (ID_IS_OVERRIDE_LIBRARY_REAL(id) &&
ELEM(lib, NULL, id->override_library->reference->lib) &&
((untagged_only == false) || !(id->tag & LIB_TAG_PRE_EXISTING))) {
BKE_lib_override_library_free(&id->override_library, true);
BKE_lib_override_library_make_local(id);
}
}
/* The check on the fourth line (LIB_TAG_PRE_EXISTING) is done so it's possible to tag data

View File

@ -1788,6 +1788,33 @@ void BKE_lib_override_library_delete(Main *bmain, ID *id_root)
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
}
/** Make given ID fully local.
*
* \note Only differs from lower-level `BKE_lib_override_library_free in infamous embedded ID
* cases.
*/
void BKE_lib_override_library_make_local(ID *id)
{
BKE_lib_override_library_free(&id->override_library, true);
Key *shape_key = BKE_key_from_id(id);
if (shape_key != NULL) {
shape_key->id.flag &= ~LIB_EMBEDDED_DATA_LIB_OVERRIDE;
}
if (GS(id->name) == ID_SCE) {
Collection *master_collection = ((Scene *)id)->master_collection;
if (master_collection != NULL) {
master_collection->id.flag &= ~LIB_EMBEDDED_DATA_LIB_OVERRIDE;
}
}
bNodeTree *node_tree = ntreeFromID(id);
if (node_tree != NULL) {
node_tree->id.flag &= ~LIB_EMBEDDED_DATA_LIB_OVERRIDE;
}
}
BLI_INLINE IDOverrideLibraryRuntime *override_library_rna_path_runtime_ensure(
IDOverrideLibrary *override)
{

View File

@ -687,7 +687,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
break;
case UI_ID_OVERRIDE:
if (id && ID_IS_OVERRIDE_LIBRARY(id)) {
BKE_lib_override_library_free(&id->override_library, true);
BKE_lib_override_library_make_local(id);
/* Reassign to get proper updates/notifiers. */
idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL);