Fix T95356: Crash in armature edit mode and certain condition

Blender would have crashed when renaming bone in Edit Mode, Saving, and
than selecting/deselecting.

Caused by a mistake in the 0f89bcdbebf5: can not "short-circuit" the
CoW update if it was explicitly requested.

Safest for now solution seems to be to store whether the CoW component
has been explicitly tagged, so that the following configuration can be
supported:

    DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
    DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);

Differential Revision: https://developer.blender.org/D13966
This commit is contained in:
Sergey Sharybin 2022-01-31 17:37:07 +01:00
parent 396413dedf
commit 6f9828289f
Notes: blender-bot 2023-02-14 04:39:18 +01:00
Referenced by commit 6bbf63f251, Fix T96054: Switching vertex group does not update display
Referenced by issue #95356, Blender crashes when renaming bone in Edit Mode, Saving, and than selecting/deselecting.
3 changed files with 9 additions and 1 deletions

View File

@ -284,6 +284,7 @@ void depsgraph_tag_component(Depsgraph *graph,
* here. */
if (component_node == nullptr) {
if (component_type == NodeType::ANIMATION) {
id_node->is_cow_explicitly_tagged = true;
depsgraph_id_tag_copy_on_write(graph, id_node, update_source);
}
return;
@ -301,6 +302,9 @@ void depsgraph_tag_component(Depsgraph *graph,
if (component_node->need_tag_cow_before_update()) {
depsgraph_id_tag_copy_on_write(graph, id_node, update_source);
}
if (component_type == NodeType::COPY_ON_WRITE) {
id_node->is_cow_explicitly_tagged = true;
}
}
/* This is a tag compatibility with legacy code.
@ -888,6 +892,7 @@ void DEG_ids_clear_recalc(Depsgraph *depsgraph, const bool backup)
* correctly when there are multiple depsgraph with others still using
* the recalc flag. */
id_node->is_user_modified = false;
id_node->is_cow_explicitly_tagged = false;
deg_graph_clear_id_recalc_flags(id_node->id_cow);
if (deg_graph->is_active) {
deg_graph_clear_id_recalc_flags(id_node->id_orig);

View File

@ -904,7 +904,7 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, const IDNode
* modifiers.
*
* TODO: Investigate modes besides edit-mode. */
if (check_datablock_expanded(id_cow)) {
if (check_datablock_expanded(id_cow) && !id_node->is_cow_explicitly_tagged) {
const ID_Type id_type = GS(id_orig->name);
if (OB_DATA_SUPPORT_EDITMODE(id_type) && BKE_object_data_is_in_editmode(id_orig)) {
/* Make sure pointers in the edit mode data are updated in the copy.

View File

@ -121,6 +121,9 @@ struct IDNode : public Node {
/* Accumulated flag from operation. Is initialized and used during updates flush. */
bool is_user_modified;
/* Copy-on-Write component has been explicitly tagged for update. */
bool is_cow_explicitly_tagged;
/* Accumulate recalc flags from multiple update passes. */
int id_cow_recalc_backup;