Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2022-08-18 18:21:28 +0300
committerBastien Montagne <bastien@blender.org>2022-08-18 18:26:12 +0300
commitf2f680d82d06da8e78eb85a31ff98afbe02f55fe (patch)
treecef3a5e82a831e2185342bc4770d22bb65ea253b /source/blender
parent96206aa98a98d7eaabbbdb77827aa53841aca1db (diff)
Fix T100475: Crash on undoing the created override from ID template.
We only need to 'manually' remap RNA ID pointer property to the newly created override if the owner itself was not already a local override. Also some more minor tweaks to notifiers sent when creating the override.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/interface/interface_ops.c20
-rw-r--r--source/blender/editors/interface/interface_templates.c13
2 files changed, 22 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index b8aa1e9660f..8976ce4ae2a 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -820,13 +820,19 @@ static int override_idtemplate_create_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- PointerRNA idptr;
- /* `idptr` is re-assigned to owner property to ensure proper updates etc. Here we also use it to
- * ensure remapping of the owner property from the linked data to the newly created liboverride
- * (note that in theory this remapping has already been done by code above). */
- RNA_id_pointer_create(id_override, &idptr);
- RNA_property_pointer_set(&owner_ptr, prop, idptr, NULL);
- RNA_property_update(C, &owner_ptr, prop);
+ if (ID_IS_OVERRIDE_LIBRARY_REAL(owner_id)) {
+ PointerRNA idptr;
+ /* `idptr` is re-assigned to owner property to ensure proper updates etc. Here we also use it
+ * to ensure remapping of the owner property from the linked data to the newly created
+ * liboverride (note that in theory this remapping has already been done by code above), but
+ * only in case owner ID was already an existing liboverride.
+ *
+ * Otherwise, owner ID will also have been overridden, and remapped already to use itsoverride
+ * of the data too. */
+ RNA_id_pointer_create(id_override, &idptr);
+ RNA_property_pointer_set(&owner_ptr, prop, idptr, NULL);
+ RNA_property_update(C, &owner_ptr, prop);
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 94a7296d558..06543e1bb86 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -796,6 +796,7 @@ ID *ui_template_id_liboverride_hierarchy_create(
BKE_lib_override_library_create(
bmain, scene, view_layer, NULL, id, NULL, NULL, &id_override, false);
BKE_scene_collections_object_remove(bmain, scene, (Object *)id, true);
+ WM_event_add_notifier(C, NC_ID | NA_REMOVED, NULL);
}
break;
case ID_ME:
@@ -862,9 +863,8 @@ ID *ui_template_id_liboverride_hierarchy_create(
* rebuild of outliner trees, leading to crashes.
*
* So for now, add some extra notifiers here. */
- WM_event_add_notifier(C, NC_ID | NA_REMOVED, NULL);
WM_event_add_notifier(C, NC_ID | NA_ADDED, NULL);
- WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL);
}
return id_override;
}
@@ -885,8 +885,13 @@ static void template_id_liboverride_hierarchy_create(bContext *C,
/* Given `idptr` is re-assigned to owner property by caller to ensure proper updates etc. Here
* we also use it to ensure remapping of the owner property from the linked data to the newly
* created liboverride (note that in theory this remapping has already been done by code
- * above). */
- RNA_id_pointer_create(id_override, idptr);
+ * above), but only in case owner ID was already an existing liboverride.
+ *
+ * Otherwise, owner ID will also have been overridden, and remapped already to use itsoverride
+ * of the data too. */
+ if (ID_IS_OVERRIDE_LIBRARY_REAL(owner_id)) {
+ RNA_id_pointer_create(id_override, idptr);
+ }
}
else {
RNA_warning("The data-block %s could not be overridden", id->name);