Fix #117760: Regression: Ctrl+Z causes Losing Audio Sound

Cused by 29aaa2922d

This change is more of a work-around, since there should be no such
tagging required. This change brings the behavior closer to what it
was before the offending commit, and solve an immediate user-level
regression.

Pull Request: https://projects.blender.org/blender/blender/pulls/117834
This commit is contained in:
Sergey Sharybin
2024-02-06 09:06:46 +01:00
committed by Sergey Sharybin
parent 3251a5b280
commit 7abc1bc7d4
@@ -184,6 +184,7 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
/* Re-tag IDs for update if it was tagged before the relations
* update tag. */
for (IDNode *id_node : graph->id_nodes) {
const ID_Type id_type = id_node->id_type;
ID *id_orig = id_node->id_orig;
id_node->finalize_build(graph);
int flag = 0;
@@ -200,21 +201,28 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
flag |= ID_RECALC_COPY_ON_WRITE;
/* This means ID is being added to the dependency graph first
* time, which is similar to "ob-visible-change" */
if (GS(id_orig->name) == ID_OB) {
if (id_type == ID_OB) {
flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
}
if (GS(id_orig->name) == ID_NT) {
if (id_type == ID_NT) {
flag |= ID_RECALC_NTREE_OUTPUT;
}
}
else {
/* Collection content might have changed (children collection might have been added or
* removed from the graph based on their inclusion and visibility flags). */
const ID_Type id_type = GS(id_node->id_cow->name);
if (id_type == ID_GR) {
/* Collection content might have changed (children collection might have been added or
* removed from the graph based on their inclusion and visibility flags). */
BKE_collection_object_cache_free(
nullptr, reinterpret_cast<Collection *>(id_node->id_cow), LIB_ID_CREATE_NO_DEG_TAG);
}
else if (id_type == ID_SCE) {
/* During undo the sequence strips might obtain a new session ID, which will disallow the
* audio handles to be re-used. Tag for the audio and sequence update to ensure the audio
* handles are open.
* MOTE: This is not something shat should be required, and perhaps indicates a weakness in
* design somewhere else. For the cause of the problem check #117760. */
flag |= ID_RECALC_AUDIO | ID_RECALC_SEQUENCER_STRIPS;
}
}
/* Restore recalc flags from original ID, which could possibly contain recalc flags set by
* an operator and then were carried on by the undo system.