From 684fd4643aefb12d8a00d5d7bbfb593156a4364c Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 14 Jan 2025 16:26:54 +0100 Subject: [PATCH] Nodes: use BKE_main_ensure_invariants directly instead of ED_node_tree_propagate_change `BKE_main_ensure_invariants` was added in 1fae5fd8f650a6d36. The older `ED_node_tree_propagate_change` was already implemented as a thin wrapper around `BKE_main_ensure_invariants`. This patch removes the wrapper and calls the more general function directly. A new overload of `BKE_main_ensure_invariants` is added for the common case when only a single data-block has been modified. Pull Request: https://projects.blender.org/blender/blender/pulls/133048 --- .../blender/blenkernel/BKE_main_invariants.hh | 6 ++ .../blenkernel/intern/main_invariants.cc | 5 ++ .../editors/curves/intern/curves_add.cc | 5 +- source/blender/editors/include/ED_node_c.hh | 17 ----- .../templates/interface_template_id.cc | 3 +- .../interface_template_node_tree_interface.cc | 9 +-- .../blender/editors/object/object_modifier.cc | 3 +- .../blender/editors/render/render_shading.cc | 7 ++- .../blender/editors/render/render_update.cc | 3 +- .../editors/sculpt_paint/paint_image_proj.cc | 3 +- .../blender/editors/space_node/clipboard.cc | 3 +- source/blender/editors/space_node/drawnode.cc | 3 +- .../editors/space_node/link_drag_search.cc | 5 +- source/blender/editors/space_node/node_add.cc | 21 ++++--- .../blender/editors/space_node/node_draw.cc | 3 +- .../blender/editors/space_node/node_edit.cc | 50 ++++++--------- .../node_geometry_attribute_search.cc | 3 +- .../blender/editors/space_node/node_group.cc | 7 ++- .../editors/space_node/node_relationships.cc | 21 ++++--- .../editors/space_node/node_templates.cc | 11 ++-- .../editors/space_outliner/outliner_tools.cc | 7 ++- .../view3d_gizmo_geometry_nodes.cc | 3 +- .../transform/transform_convert_node.cc | 3 +- source/blender/editors/uvedit/uvedit_ops.cc | 3 +- source/blender/makesrna/intern/rna_color.cc | 3 +- source/blender/makesrna/intern/rna_image.cc | 3 +- .../blender/makesrna/intern/rna_main_api.cc | 3 +- .../makesrna/intern/rna_node_socket.cc | 5 +- .../intern/rna_node_tree_interface.cc | 17 ++--- .../blender/makesrna/intern/rna_nodetree.cc | 63 ++++++++++--------- source/blender/makesrna/intern/rna_scene.cc | 3 +- source/blender/makesrna/intern/rna_texture.cc | 3 +- source/blender/nodes/NOD_socket_items_ops.hh | 3 +- 33 files changed, 160 insertions(+), 147 deletions(-) diff --git a/source/blender/blenkernel/BKE_main_invariants.hh b/source/blender/blenkernel/BKE_main_invariants.hh index 617afec6098..8a77b0e26b1 100644 --- a/source/blender/blenkernel/BKE_main_invariants.hh +++ b/source/blender/blenkernel/BKE_main_invariants.hh @@ -36,3 +36,9 @@ struct ID; */ void BKE_main_ensure_invariants(Main &bmain, std::optional> modified_ids = std::nullopt); + +/** + * Same as above but the calling code is less verbose in the common case when only a single + * data-block has been modified. + */ +void BKE_main_ensure_invariants(Main &bmain, ID &modified_id); diff --git a/source/blender/blenkernel/intern/main_invariants.cc b/source/blender/blenkernel/intern/main_invariants.cc index fc8d91402ed..ee738d613ad 100644 --- a/source/blender/blenkernel/intern/main_invariants.cc +++ b/source/blender/blenkernel/intern/main_invariants.cc @@ -68,3 +68,8 @@ void BKE_main_ensure_invariants(Main &bmain, const std::optionalid); bke::node_add_link(ntree, group_input, @@ -105,7 +106,7 @@ void ensure_surface_deformation_node_exists(bContext &C, Object &curves_ob) group_output->location[0] = 200; deform_node->location[0] = 0; - ED_node_tree_propagate_change(*bmain, nmd.node_group); + BKE_main_ensure_invariants(*bmain, nmd.node_group->id); } bke::CurvesGeometry primitive_random_sphere(const int curves_size, const int points_per_curve) diff --git a/source/blender/editors/include/ED_node_c.hh b/source/blender/editors/include/ED_node_c.hh index 5a30ac601d9..3a0873cb23d 100644 --- a/source/blender/editors/include/ED_node_c.hh +++ b/source/blender/editors/include/ED_node_c.hh @@ -93,23 +93,6 @@ void ED_node_post_apply_transform(bContext *C, bNodeTree *ntree); void ED_node_set_active( Main *bmain, SpaceNode *snode, bNodeTree *ntree, bNode *node, bool *r_active_texture_changed); -/** - * Call after one or more node trees have been changed and tagged accordingly. - * - * This function will make sure that other parts of Blender update accordingly. For example, if the - * node group interface changed, parent node groups have to be updated as well. - * - * Additionally, this will send notifiers and tag the depsgraph based on the changes. Depsgraph - * relation updates have to be triggered by the caller. - * - * \param bmain: Main whose data-blocks should be updated based on the changes. - * \param ntree: Under some circumstances the caller knows that only one node tree has - * changed since the last update. In this case the function may be able to skip scanning #bmain - * for other things that have to be changed. It may still scan #bmain if the interface of the - * node tree has changed. - */ -void ED_node_tree_propagate_change(Main &bmain, bNodeTree *ntree = nullptr); - /** * \param scene_owner: is the owner of the job, * we don't use it for anything else currently so could also be a void pointer, diff --git a/source/blender/editors/interface/templates/interface_template_id.cc b/source/blender/editors/interface/templates/interface_template_id.cc index f7341897678..c8f40454655 100644 --- a/source/blender/editors/interface/templates/interface_template_id.cc +++ b/source/blender/editors/interface/templates/interface_template_id.cc @@ -14,6 +14,7 @@ #include "BKE_lib_id.hh" #include "BKE_lib_override.hh" #include "BKE_main.hh" +#include "BKE_main_invariants.hh" #include "BKE_packedFile.hh" #include "BLI_string.h" @@ -771,7 +772,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, nullptr); DEG_relations_tag_update(bmain); } - ED_node_tree_propagate_change(*CTX_data_main(C)); + BKE_main_ensure_invariants(*CTX_data_main(C)); undo_push_label = "Make Single User"; } break; diff --git a/source/blender/editors/interface/templates/interface_template_node_tree_interface.cc b/source/blender/editors/interface/templates/interface_template_node_tree_interface.cc index 137fc5f2b13..3c2493f8ed4 100644 --- a/source/blender/editors/interface/templates/interface_template_node_tree_interface.cc +++ b/source/blender/editors/interface/templates/interface_template_node_tree_interface.cc @@ -7,6 +7,7 @@ */ #include "BKE_context.hh" +#include "BKE_main_invariants.hh" #include "BKE_node_tree_interface.hh" #include "BKE_node_tree_update.hh" @@ -157,7 +158,7 @@ class NodeSocketViewItem : public BasicTreeViewItem { socket_.name = BLI_strdup(new_name.c_str()); nodetree_.tree_interface.tag_items_changed(); - ED_node_tree_propagate_change(*CTX_data_main(&C), &nodetree_); + BKE_main_ensure_invariants(*CTX_data_main(&C), nodetree_.id); ED_undo_push(&const_cast(C), new_name.c_str()); return true; } @@ -217,7 +218,7 @@ class NodePanelViewItem : public BasicTreeViewItem { panel_.name = BLI_strdup(new_name.c_str()); nodetree_.tree_interface.tag_items_changed(); - ED_node_tree_propagate_change(*CTX_data_main(&C), &nodetree_); + BKE_main_ensure_invariants(*CTX_data_main(&C), nodetree_.id); return true; } StringRef get_rename_string() const override @@ -395,7 +396,7 @@ bool NodeSocketDropTarget::on_drop(bContext *C, const DragInfo &drag_info) const interface.move_item_to_parent(*drag_item, parent, index); /* General update */ - ED_node_tree_propagate_change(*CTX_data_main(C), &nodetree); + BKE_main_ensure_invariants(*CTX_data_main(C), nodetree.id); ED_undo_push(C, "Insert node group item"); return true; } @@ -485,7 +486,7 @@ bool NodePanelDropTarget::on_drop(bContext *C, const DragInfo &drag_info) const interface.move_item_to_parent(*drag_item, parent, index); /* General update */ - ED_node_tree_propagate_change(*CTX_data_main(C), &nodetree); + BKE_main_ensure_invariants(*CTX_data_main(C), nodetree.id); ED_undo_push(C, "Insert node group item"); return true; } diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index e512d51fd26..99455e72db1 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -58,6 +58,7 @@ #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_main_invariants.hh" #include "BKE_material.hh" #include "BKE_mball.hh" #include "BKE_mesh.hh" @@ -3802,7 +3803,7 @@ static int geometry_node_tree_copy_assign_exec(bContext *C, wmOperator * /*op*/) nmd->node_group = new_tree; id_us_min(&tree->id); - ED_node_tree_propagate_change(*bmain, new_tree); + BKE_main_ensure_invariants(*bmain); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); DEG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc index 542aeb5f8f4..5ef00a5b64f 100644 --- a/source/blender/editors/render/render_shading.cc +++ b/source/blender/editors/render/render_shading.cc @@ -50,6 +50,7 @@ #include "BKE_lightprobe.h" #include "BKE_linestyle.h" #include "BKE_main.hh" +#include "BKE_main_invariants.hh" #include "BKE_material.hh" #include "BKE_node.hh" #include "BKE_node_runtime.hh" @@ -1642,7 +1643,7 @@ static int render_view_add_exec(bContext *C, wmOperator * /*op*/) WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); BKE_ntree_update_tag_id_changed(bmain, &scene->id); - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); return OPERATOR_FINISHED; } @@ -1681,7 +1682,7 @@ static int render_view_remove_exec(bContext *C, wmOperator * /*op*/) WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); BKE_ntree_update_tag_id_changed(bmain, &scene->id); - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); return OPERATOR_FINISHED; } @@ -2835,7 +2836,7 @@ static int paste_material_exec(bContext *C, wmOperator *op) /* There are some custom updates to the node tree above, better do a full update pass. */ BKE_ntree_update_tag_all(ma->nodetree); - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); DEG_id_tag_update(&ma->id, ID_RECALC_SYNC_TO_EVAL); WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma); diff --git a/source/blender/editors/render/render_update.cc b/source/blender/editors/render/render_update.cc index eff942b2d6c..dfb8ad7ede0 100644 --- a/source/blender/editors/render/render_update.cc +++ b/source/blender/editors/render/render_update.cc @@ -31,6 +31,7 @@ #include "BKE_context.hh" #include "BKE_icons.h" #include "BKE_main.hh" +#include "BKE_main_invariants.hh" #include "BKE_material.hh" #include "BKE_paint.hh" #include "BKE_scene.hh" @@ -201,7 +202,7 @@ void ED_render_engine_changed(Main *bmain, const bool update_scene_data) ntreeCompositUpdateRLayers(scene->nodetree); } } - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); /* Update #CacheFiles to ensure that procedurals are properly taken into account. */ LISTBASE_FOREACH (CacheFile *, cachefile, &bmain->cachefiles) { diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc b/source/blender/editors/sculpt_paint/paint_image_proj.cc index 6ef0b76ba94..cb814fe6fb6 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc @@ -63,6 +63,7 @@ #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_main_invariants.hh" #include "BKE_material.hh" #include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" @@ -6777,7 +6778,7 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) } } - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); /* In case we added more than one node, position them too. */ blender::bke::node_position_propagate(out_node); diff --git a/source/blender/editors/space_node/clipboard.cc b/source/blender/editors/space_node/clipboard.cc index 1ff93a97c49..f4a8ace076d 100644 --- a/source/blender/editors/space_node/clipboard.cc +++ b/source/blender/editors/space_node/clipboard.cc @@ -10,6 +10,7 @@ #include "BKE_lib_query.hh" #include "BKE_main.hh" #include "BKE_main_idmap.hh" +#include "BKE_main_invariants.hh" #include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_report.hh" @@ -473,7 +474,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) update_multi_input_indices_for_removed_links(*new_node); } - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); /* Pasting nodes can create arbitrary new relations because nodes can reference IDs. */ DEG_relations_tag_update(bmain); diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 62ceea643ca..58852947f3a 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -20,6 +20,7 @@ #include "BKE_curve.hh" #include "BKE_image.hh" #include "BKE_main.hh" +#include "BKE_main_invariants.hh" #include "BKE_node.hh" #include "BKE_node_enum.hh" #include "BKE_node_legacy_types.hh" @@ -1008,7 +1009,7 @@ static void node_property_update_default(Main *bmain, Scene * /*scene*/, Pointer bNodeTree *ntree = (bNodeTree *)ptr->owner_id; bNode *node = (bNode *)ptr->data; BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); } static void node_socket_template_properties_update(blender::bke::bNodeType *ntype, diff --git a/source/blender/editors/space_node/link_drag_search.cc b/source/blender/editors/space_node/link_drag_search.cc index fff7b6cb1ad..5df877f3fb2 100644 --- a/source/blender/editors/space_node/link_drag_search.cc +++ b/source/blender/editors/space_node/link_drag_search.cc @@ -13,6 +13,7 @@ #include "BKE_context.hh" #include "BKE_idprop.hh" #include "BKE_lib_id.hh" +#include "BKE_main_invariants.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" #include "BKE_screen.hh" @@ -99,7 +100,7 @@ static void add_group_input_node_fn(nodes::LinkSearchOpParams ¶ms) bNode &group_input = params.add_node("NodeGroupInput"); /* This is necessary to create the new sockets in the other input nodes. */ - ED_node_tree_propagate_change(*CTX_data_main(¶ms.C), ¶ms.node_tree); + BKE_main_ensure_invariants(*CTX_data_main(¶ms.C), params.node_tree.id); /* Hide the new input in all other group input nodes, to avoid making them taller. */ for (bNode *node : params.node_tree.all_nodes()) { @@ -384,7 +385,7 @@ static void link_drag_search_exec_fn(bContext *C, void *arg1, void *arg2) /* Ideally it would be possible to tag the node tree in some way so it updates only after the * translate operation is finished, but normally moving nodes around doesn't cause updates. */ - ED_node_tree_propagate_change(bmain, &node_tree); + BKE_main_ensure_invariants(bmain, node_tree.id); /* Start translation operator with the new node. */ wmOperatorType *ot = WM_operatortype_find("NODE_OT_translate_attach_remove_on_cancel", true); diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index 57ce16619c6..8f21139de9c 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -26,6 +26,7 @@ #include "BKE_image.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_main_invariants.hh" #include "BKE_node.hh" #include "BKE_node_legacy_types.hh" #include "BKE_node_runtime.hh" @@ -87,7 +88,7 @@ bNode *add_node(const bContext &C, const StringRef idname, const float2 &locatio bke::node_set_selected(node, true); ED_node_set_active(&bmain, &snode, &node_tree, node, nullptr); - ED_node_tree_propagate_change(bmain, &node_tree); + BKE_main_ensure_invariants(bmain, node_tree.id); return node; } @@ -107,7 +108,7 @@ bNode *add_static_node(const bContext &C, int type, const float2 &location) bke::node_set_selected(node, true); ED_node_set_active(&bmain, &snode, &node_tree, node, nullptr); - ED_node_tree_propagate_change(bmain, &node_tree); + BKE_main_ensure_invariants(bmain, node_tree.id); return node; } @@ -224,7 +225,7 @@ static int add_reroute_exec(bContext *C, wmOperator *op) } } - ED_node_tree_propagate_change(*CTX_data_main(C), &ntree); + BKE_main_ensure_invariants(*CTX_data_main(C), ntree.id); return OPERATOR_FINISHED; } @@ -330,7 +331,7 @@ static int node_add_group_exec(bContext *C, wmOperator *op) BKE_ntree_update_tag_node_property(snode->edittree, group_node); bke::node_set_active(ntree, group_node); - ED_node_tree_propagate_change(*bmain, nullptr); + BKE_main_ensure_invariants(*bmain); WM_event_add_notifier(C, NC_NODE | NA_ADDED, nullptr); DEG_relations_tag_update(bmain); return OPERATOR_FINISHED; @@ -433,7 +434,7 @@ static bool add_node_group_asset(const bContext &C, BKE_ntree_update_tag_node_property(&edit_tree, group_node); bke::node_set_active(&edit_tree, group_node); - ED_node_tree_propagate_change(bmain, nullptr); + BKE_main_ensure_invariants(bmain); WM_event_add_notifier(&C, NC_NODE | NA_ADDED, nullptr); DEG_relations_tag_update(&bmain); @@ -544,7 +545,7 @@ static int node_add_object_exec(bContext *C, wmOperator *op) BKE_ntree_update_tag_socket_property(ntree, sock); bke::node_set_active(ntree, object_node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); DEG_relations_tag_update(bmain); return OPERATOR_FINISHED; @@ -631,7 +632,7 @@ static int node_add_collection_exec(bContext *C, wmOperator *op) BKE_ntree_update_tag_socket_property(&ntree, sock); bke::node_set_active(&ntree, collection_node); - ED_node_tree_propagate_change(*bmain, &ntree); + BKE_main_ensure_invariants(*bmain, ntree.id); DEG_relations_tag_update(bmain); return OPERATOR_FINISHED; @@ -825,7 +826,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - ED_node_tree_propagate_change(*bmain, snode.edittree); + BKE_main_ensure_invariants(*bmain, snode.edittree->id); DEG_relations_tag_update(bmain); if (nodes.size() == 1) { @@ -927,7 +928,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op) node->id = mask; id_us_plus(mask); - ED_node_tree_propagate_change(*bmain, snode.edittree); + BKE_main_ensure_invariants(*bmain, snode.edittree->id); DEG_relations_tag_update(bmain); return OPERATOR_FINISHED; @@ -980,7 +981,7 @@ static int node_add_material_exec(bContext *C, wmOperator *op) material_node->id = &material->id; id_us_plus(&material->id); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); DEG_relations_tag_update(bmain); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 77a45c9f77f..f181a22a71a 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -44,6 +44,7 @@ #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_main_invariants.hh" #include "BKE_node.hh" #include "BKE_node_enum.hh" #include "BKE_node_legacy_types.hh" @@ -2378,7 +2379,7 @@ static void node_panel_toggle_button_cb(bContext *C, void *panel_state_argv, voi panel_state->flag ^= NODE_PANEL_COLLAPSED; - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } /* Draw panel backgrounds first, so other node elements can be rendered on top. */ diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index cf69b154567..fd3641ba4c4 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -469,16 +469,6 @@ bool composite_node_editable(bContext *C) /** \name Node Editor Public API Functions * \{ */ -void ED_node_tree_propagate_change(Main &bmain, bNodeTree *root_ntree) -{ - if (root_ntree) { - BKE_main_ensure_invariants(bmain, {{&root_ntree->id}}); - } - else { - BKE_main_ensure_invariants(bmain); - } -} - void ED_node_set_tree_type(SpaceNode *snode, blender::bke::bNodeTreeType *typeinfo) { if (typeinfo) { @@ -737,7 +727,7 @@ void ED_node_set_active( BKE_ntree_update_tag_active_output_changed(ntree); } - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); if ((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) { /* If active texture changed, free GLSL materials. */ @@ -781,7 +771,7 @@ void ED_node_set_active( if (r_active_texture_changed) { *r_active_texture_changed = true; } - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_IMAGE, nullptr); } @@ -799,7 +789,7 @@ void ED_node_set_active( node->flag |= NODE_DO_OUTPUT; if (was_output == 0) { BKE_ntree_update_tag_active_output_changed(ntree); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } /* Adding a node doesn't link this yet. */ @@ -815,11 +805,11 @@ void ED_node_set_active( node->flag |= NODE_DO_OUTPUT; BKE_ntree_update_tag_active_output_changed(ntree); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } } else if (do_update) { - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } } else if (ntree->type == NTREE_GEOMETRY) { @@ -1487,7 +1477,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } tree_draw_order_update(*snode->edittree); - ED_node_tree_propagate_change(*bmain, snode->edittree); + BKE_main_ensure_invariants(*bmain, snode->edittree->id); return OPERATOR_FINISHED; } @@ -1550,7 +1540,7 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator * /*op*/) } } - ED_node_tree_propagate_change(*bmain, &edit_tree); + BKE_main_ensure_invariants(*bmain, edit_tree.id); return OPERATOR_FINISHED; } @@ -1716,7 +1706,7 @@ static int node_preview_toggle_exec(bContext *C, wmOperator * /*op*/) node_flag_toggle_exec(snode, NODE_PREVIEW); - ED_node_tree_propagate_change(*CTX_data_main(C), snode->edittree); + BKE_main_ensure_invariants(*CTX_data_main(C), snode->edittree->id); return OPERATOR_FINISHED; } @@ -1767,7 +1757,7 @@ static int node_deactivate_viewer_exec(bContext *C, wmOperator * /*op*/) } } - ED_node_tree_propagate_change(*CTX_data_main(C), snode.edittree); + BKE_main_ensure_invariants(*CTX_data_main(C), snode.edittree->id); return OPERATOR_FINISHED; } @@ -1846,7 +1836,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator * /*op*/) } } - ED_node_tree_propagate_change(*CTX_data_main(C), snode->edittree); + BKE_main_ensure_invariants(*CTX_data_main(C), snode->edittree->id); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr); /* Hack to force update of the button state after drawing, see #112462. */ @@ -1890,7 +1880,7 @@ static int node_mute_exec(bContext *C, wmOperator * /*op*/) } } - ED_node_tree_propagate_change(*bmain, snode->edittree); + BKE_main_ensure_invariants(*bmain, snode->edittree->id); return OPERATOR_FINISHED; } @@ -1932,7 +1922,7 @@ static int node_delete_exec(bContext *C, wmOperator * /*op*/) } } - ED_node_tree_propagate_change(*bmain, snode->edittree); + BKE_main_ensure_invariants(*bmain, snode->edittree->id); return OPERATOR_FINISHED; } @@ -1979,7 +1969,7 @@ static int node_delete_reconnect_exec(bContext *C, wmOperator * /*op*/) } } - ED_node_tree_propagate_change(*bmain, snode->edittree); + BKE_main_ensure_invariants(*bmain, snode->edittree->id); return OPERATOR_FINISHED; } @@ -2030,7 +2020,7 @@ static int node_output_file_add_socket_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "file_path", file_path); ntreeCompositOutputFileAddSocket(ntree, node, file_path, &scene->r.im_format); - ED_node_tree_propagate_change(*CTX_data_main(C), snode->edittree); + BKE_main_ensure_invariants(*CTX_data_main(C), snode->edittree->id); return OPERATOR_FINISHED; } @@ -2083,7 +2073,7 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator * return OPERATOR_CANCELLED; } - ED_node_tree_propagate_change(*CTX_data_main(C), ntree); + BKE_main_ensure_invariants(*CTX_data_main(C), ntree->id); return OPERATOR_FINISHED; } @@ -2155,7 +2145,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) } BKE_ntree_update_tag_node_property(snode->edittree, node); - ED_node_tree_propagate_change(*CTX_data_main(C), snode->edittree); + BKE_main_ensure_invariants(*CTX_data_main(C), snode->edittree->id); return OPERATOR_FINISHED; } @@ -2438,7 +2428,7 @@ static int viewer_border_exec(bContext *C, wmOperator *op) btree->flag |= NTREE_VIEWER_BORDER; } - ED_node_tree_propagate_change(*bmain, btree); + BKE_main_ensure_invariants(*bmain, btree->id); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr); } else { @@ -2478,7 +2468,7 @@ static int clear_viewer_border_exec(bContext *C, wmOperator * /*op*/) bNodeTree *btree = snode->nodetree; btree->flag &= ~NTREE_VIEWER_BORDER; - ED_node_tree_propagate_change(*CTX_data_main(C), btree); + BKE_main_ensure_invariants(*CTX_data_main(C), btree->id); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr); return OPERATOR_FINISHED; @@ -2527,7 +2517,7 @@ static int node_cryptomatte_add_socket_exec(bContext *C, wmOperator * /*op*/) ntreeCompositCryptomatteAddSocket(ntree, node); - ED_node_tree_propagate_change(*CTX_data_main(C), ntree); + BKE_main_ensure_invariants(*CTX_data_main(C), ntree->id); return OPERATOR_FINISHED; } @@ -2577,7 +2567,7 @@ static int node_cryptomatte_remove_socket_exec(bContext *C, wmOperator * /*op*/) return OPERATOR_CANCELLED; } - ED_node_tree_propagate_change(*CTX_data_main(C), ntree); + BKE_main_ensure_invariants(*CTX_data_main(C), ntree->id); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_node/node_geometry_attribute_search.cc b/source/blender/editors/space_node/node_geometry_attribute_search.cc index 9ef85be1417..c8fd21c2ede 100644 --- a/source/blender/editors/space_node/node_geometry_attribute_search.cc +++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc @@ -11,6 +11,7 @@ #include "DNA_space_types.h" #include "BKE_context.hh" +#include "BKE_main_invariants.hh" #include "BKE_node_legacy_types.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" @@ -205,7 +206,7 @@ static void attribute_search_exec_fn(bContext *C, void *data_v, void *item_v) /* Make the output socket with the new type on the attribute input node active. */ nodes::update_node_declaration_and_sockets(*node_tree, *node); BKE_ntree_update_tag_node_property(node_tree, node); - ED_node_tree_propagate_change(*CTX_data_main(C), node_tree); + BKE_main_ensure_invariants(*CTX_data_main(C), node_tree->id); } } diff --git a/source/blender/editors/space_node/node_group.cc b/source/blender/editors/space_node/node_group.cc index f7b554f4cff..8aa15287966 100644 --- a/source/blender/editors/space_node/node_group.cc +++ b/source/blender/editors/space_node/node_group.cc @@ -29,6 +29,7 @@ #include "BKE_context.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_main_invariants.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" #include "BKE_report.hh" @@ -482,7 +483,7 @@ static int node_group_ungroup_exec(bContext *C, wmOperator * /*op*/) for (bNode *node : nodes_to_ungroup) { node_group_ungroup(bmain, snode->edittree, node); } - ED_node_tree_propagate_change(*CTX_data_main(C)); + BKE_main_ensure_invariants(*CTX_data_main(C)); return OPERATOR_FINISHED; } @@ -667,7 +668,7 @@ static int node_group_separate_exec(bContext *C, wmOperator *op) /* switch to parent tree */ ED_node_tree_pop(snode); - ED_node_tree_propagate_change(*CTX_data_main(C)); + BKE_main_ensure_invariants(*CTX_data_main(C)); return OPERATOR_FINISHED; } @@ -1200,7 +1201,7 @@ static void node_group_make_insert_selected(const bContext &C, update_nested_node_refs_after_moving_nodes_into_group(ntree, group, *gnode, node_identifier_map); - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); } static bNode *node_group_make_from_nodes(const bContext &C, diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index 53bb5e2c481..99502402cfd 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -15,6 +15,7 @@ #include "BLI_stack.hh" #include "BKE_context.hh" +#include "BKE_main_invariants.hh" #include "BKE_node.hh" #include "BKE_node_legacy_types.hh" #include "BKE_node_runtime.hh" @@ -582,7 +583,7 @@ static void finalize_viewer_link(const bContext &C, if (snode.edittree->type == NTREE_GEOMETRY) { viewer_path::activate_geometry_node(*bmain, snode, viewer_node); } - ED_node_tree_propagate_change(*bmain, snode.edittree); + BKE_main_ensure_invariants(*bmain, snode.edittree->id); } static const bNode *find_overlapping_node(const bNodeTree &tree, @@ -847,7 +848,7 @@ static int node_active_link_viewer_exec(bContext *C, wmOperator * /*op*/) return OPERATOR_CANCELLED; } - ED_node_tree_propagate_change(*CTX_data_main(C), snode.edittree); + BKE_main_ensure_invariants(*CTX_data_main(C), snode.edittree->id); return OPERATOR_FINISHED; } @@ -1229,7 +1230,7 @@ static void add_dragged_links_to_tree(bContext &C, bNodeLinkDrag &nldrag) BKE_ntree_update_tag_link_added(&ntree, new_link); } - ED_node_tree_propagate_change(*bmain, &ntree); + BKE_main_ensure_invariants(*bmain, ntree.id); /* Ensure drag-link tool-tip is disabled. */ draw_draglink_tooltip_deactivate(region, nldrag); @@ -1250,7 +1251,7 @@ static void node_link_cancel(bContext *C, wmOperator *op) snode->runtime->linkdrag.reset(); clear_picking_highlight(&snode->edittree->links); BKE_ntree_update_tag_link_removed(snode->edittree); - ED_node_tree_propagate_change(*CTX_data_main(C), snode->edittree); + BKE_main_ensure_invariants(*CTX_data_main(C), snode->edittree->id); } static void node_link_find_socket(bContext &C, wmOperator &op, const float2 &cursor) @@ -1617,7 +1618,7 @@ static int node_make_link_exec(bContext *C, wmOperator *op) node_deselect_all_input_sockets(node_tree, false); node_deselect_all_output_sockets(node_tree, false); - ED_node_tree_propagate_change(bmain, &node_tree); + BKE_main_ensure_invariants(bmain, node_tree.id); return OPERATOR_FINISHED; } @@ -1706,7 +1707,7 @@ static int cut_links_exec(bContext *C, wmOperator *op) update_multi_input_indices_for_removed_links(*node); } - ED_node_tree_propagate_change(*CTX_data_main(C), snode.edittree); + BKE_main_ensure_invariants(*CTX_data_main(C), snode.edittree->id); if (found) { return OPERATOR_FINISHED; } @@ -1836,7 +1837,7 @@ static int mute_links_exec(bContext *C, wmOperator *op) } } - ED_node_tree_propagate_change(*CTX_data_main(C), &ntree); + BKE_main_ensure_invariants(*CTX_data_main(C), ntree.id); return OPERATOR_FINISHED; } @@ -1884,7 +1885,7 @@ static int detach_links_exec(bContext *C, wmOperator * /*op*/) } } - ED_node_tree_propagate_change(*CTX_data_main(C), &ntree); + BKE_main_ensure_invariants(*CTX_data_main(C), ntree.id); return OPERATOR_FINISHED; } @@ -2055,7 +2056,7 @@ static int node_join_exec(bContext *C, wmOperator * /*op*/) } tree_draw_order_update(ntree); - ED_node_tree_propagate_change(bmain, snode.edittree); + BKE_main_ensure_invariants(bmain, snode.edittree->id); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr); return OPERATOR_FINISHED; @@ -2488,7 +2489,7 @@ void node_insert_on_link_flags(Main &bmain, SpaceNode &snode, bool is_new_node) snode.runtime->iofsd = iofsd; } - ED_node_tree_propagate_change(bmain, &ntree); + BKE_main_ensure_invariants(bmain, ntree.id); } /** \} */ diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc index 1d87daf0e80..95032c6a20e 100644 --- a/source/blender/editors/space_node/node_templates.cc +++ b/source/blender/editors/space_node/node_templates.cc @@ -25,6 +25,7 @@ #include "BKE_context.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_main_invariants.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" @@ -177,7 +178,7 @@ static void node_socket_disconnect(Main *bmain, sock_to->flag |= SOCK_COLLAPSED; BKE_ntree_update_tag_node_property(ntree, node_to); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } /* remove all nodes connected to this socket, if they aren't connected to other nodes */ @@ -191,7 +192,7 @@ static void node_socket_remove(Main *bmain, bNodeTree *ntree, bNode *node_to, bN sock_to->flag |= SOCK_COLLAPSED; BKE_ntree_update_tag_node_property(ntree, node_to); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } /* add new node connected to this socket, or replace an existing one */ @@ -245,7 +246,7 @@ static void node_socket_add_replace(const bContext *C, } node_link_item_apply(ntree, node_from, item); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } bke::node_set_active(ntree, node_from); @@ -295,7 +296,7 @@ static void node_socket_add_replace(const bContext *C, BKE_ntree_update_tag_node_property(ntree, node_from); BKE_ntree_update_tag_node_property(ntree, node_to); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } /****************************** Node Link Menu *******************************/ @@ -733,7 +734,7 @@ static void node_panel_toggle_button_cb(bContext *C, void *panel_state_argv, voi panel_state->flag ^= NODE_PANEL_COLLAPSED; - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); /* Make sure panel state updates from the Properties Editor, too. */ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_NODE_VIEW, nullptr); diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index afe5647e203..4e4f23f1c0e 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -53,6 +53,7 @@ #include "BKE_lib_query.hh" #include "BKE_lib_remap.hh" #include "BKE_main.hh" +#include "BKE_main_invariants.hh" #include "BKE_object.hh" #include "BKE_report.hh" #include "BKE_scene.hh" @@ -2722,7 +2723,7 @@ static int outliner_delete_exec(bContext *C, wmOperator *op) WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active); } - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -3021,7 +3022,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) break; } - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); /* wrong notifier still... */ WM_event_add_notifier(C, NC_ID | NA_EDITED, nullptr); @@ -3112,7 +3113,7 @@ static int outliner_lib_operation_exec(bContext *C, wmOperator *op) break; } - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); /* wrong notifier still... */ WM_event_add_notifier(C, NC_ID | NA_EDITED, nullptr); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_geometry_nodes.cc b/source/blender/editors/space_view3d/view3d_gizmo_geometry_nodes.cc index f35f51d3c9a..a26e55877c7 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_geometry_nodes.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_geometry_nodes.cc @@ -21,6 +21,7 @@ #include "BKE_geometry_set_instances.hh" #include "BKE_idprop.hh" #include "BKE_instances.hh" +#include "BKE_main_invariants.hh" #include "BKE_modifier.hh" #include "BKE_node_legacy_types.hh" #include "BKE_node_runtime.hh" @@ -1073,7 +1074,7 @@ static void WIDGETGROUP_geometry_nodes_refresh(const bContext *C, wmGizmoGroup * modify_value); Main *main = CTX_data_main(C); - ED_node_tree_propagate_change(*main); + BKE_main_ensure_invariants(*main); WM_main_add_notifier(NC_GEOM | ND_DATA, nullptr); }; } diff --git a/source/blender/editors/transform/transform_convert_node.cc b/source/blender/editors/transform/transform_convert_node.cc index cc8ab181433..466e5cfacdf 100644 --- a/source/blender/editors/transform/transform_convert_node.cc +++ b/source/blender/editors/transform/transform_convert_node.cc @@ -16,6 +16,7 @@ #include "BLI_rect.h" #include "BKE_context.hh" +#include "BKE_main_invariants.hh" #include "BKE_node.hh" #include "BKE_node_runtime.hh" @@ -280,7 +281,7 @@ static void special_aftertrans_update__node(bContext *C, TransInfo *t) bke::node_remove_node(bmain, ntree, node, true); } } - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } } diff --git a/source/blender/editors/uvedit/uvedit_ops.cc b/source/blender/editors/uvedit/uvedit_ops.cc index a1625e970c2..e361743cd95 100644 --- a/source/blender/editors/uvedit/uvedit_ops.cc +++ b/source/blender/editors/uvedit/uvedit_ops.cc @@ -33,6 +33,7 @@ #include "BKE_customdata.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" +#include "BKE_main_invariants.hh" #include "BKE_material.hh" #include "BKE_mesh_mapping.hh" #include "BKE_mesh_types.hh" @@ -171,7 +172,7 @@ void ED_object_assign_active_image(Main *bmain, Object *ob, int mat_nr, Image *i if (node && is_image_texture_node(node)) { node->id = &ima->id; - ED_node_tree_propagate_change(*bmain, ma->nodetree); + BKE_main_ensure_invariants(*bmain, ma->nodetree->id); } } diff --git a/source/blender/makesrna/intern/rna_color.cc b/source/blender/makesrna/intern/rna_color.cc index 5e99b0461c3..ae10c159bd1 100644 --- a/source/blender/makesrna/intern/rna_color.cc +++ b/source/blender/makesrna/intern/rna_color.cc @@ -16,6 +16,7 @@ #include "BLT_translation.hh" +#include "BKE_main_invariants.hh" #include "BKE_node_tree_update.hh" #include "RNA_define.hh" @@ -360,7 +361,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr for (node = static_cast(ntree->nodes.first); node; node = node->next) { if (ELEM(node->type_legacy, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) { BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } } break; diff --git a/source/blender/makesrna/intern/rna_image.cc b/source/blender/makesrna/intern/rna_image.cc index d635b884c64..c47455902b4 100644 --- a/source/blender/makesrna/intern/rna_image.cc +++ b/source/blender/makesrna/intern/rna_image.cc @@ -16,6 +16,7 @@ #include "BKE_image.hh" #include "BKE_image_format.hh" +#include "BKE_main_invariants.hh" #include "BKE_node_tree_update.hh" #include "BLT_translation.hh" @@ -254,7 +255,7 @@ static void rna_ImageUser_update(Main *bmain, Scene *scene, PointerRNA *ptr) if (GS(id->name) == ID_NT) { /* Special update for node-trees. */ BKE_ntree_update_tag_image_user_changed((bNodeTree *)id, iuser); - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); } else { /* Update material or texture for render preview. */ diff --git a/source/blender/makesrna/intern/rna_main_api.cc b/source/blender/makesrna/intern/rna_main_api.cc index 21bb6df6fb6..6fbc1b04427 100644 --- a/source/blender/makesrna/intern/rna_main_api.cc +++ b/source/blender/makesrna/intern/rna_main_api.cc @@ -43,6 +43,7 @@ # include "BKE_light.h" # include "BKE_lightprobe.h" # include "BKE_linestyle.h" +# include "BKE_main_invariants.hh" # include "BKE_mask.h" # include "BKE_material.hh" # include "BKE_mball.hh" @@ -293,7 +294,7 @@ static bNodeTree *rna_Main_nodetree_new(Main *bmain, const char *name, int type) blender::bke::bNodeTreeType *typeinfo = rna_node_tree_type_from_enum(type); if (typeinfo) { bNodeTree *ntree = blender::bke::node_tree_add_tree(bmain, safe_name, typeinfo->idname); - ED_node_tree_propagate_change(*bmain); + BKE_main_ensure_invariants(*bmain); id_us_min(&ntree->id); return ntree; diff --git a/source/blender/makesrna/intern/rna_node_socket.cc b/source/blender/makesrna/intern/rna_node_socket.cc index 605529d241d..1bcbe174943 100644 --- a/source/blender/makesrna/intern/rna_node_socket.cc +++ b/source/blender/makesrna/intern/rna_node_socket.cc @@ -47,6 +47,7 @@ const EnumPropertyItem rna_enum_node_socket_type_items[] = { # include "BLI_string_ref.hh" +# include "BKE_main_invariants.hh" # include "BKE_node.hh" # include "BKE_node_enum.hh" # include "BKE_node_runtime.hh" @@ -350,7 +351,7 @@ static void rna_NodeSocket_update(Main *bmain, Scene * /*scene*/, PointerRNA *pt bNodeSocket *sock = static_cast(ptr->data); BKE_ntree_update_tag_socket_property(ntree, sock); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } static void rna_NodeSocket_enabled_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr) @@ -359,7 +360,7 @@ static void rna_NodeSocket_enabled_update(Main *bmain, Scene * /*scene*/, Pointe bNodeSocket *sock = static_cast(ptr->data); BKE_ntree_update_tag_socket_availability(ntree, sock); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } static bool rna_NodeSocket_is_output_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_node_tree_interface.cc b/source/blender/makesrna/intern/rna_node_tree_interface.cc index 2a110e3c12f..f5024714c83 100644 --- a/source/blender/makesrna/intern/rna_node_tree_interface.cc +++ b/source/blender/makesrna/intern/rna_node_tree_interface.cc @@ -33,6 +33,7 @@ static const EnumPropertyItem node_tree_interface_socket_in_out_items[] = { # include "BLI_string_ref.hh" # include "BKE_attribute.hh" +# include "BKE_main_invariants.hh" # include "BKE_node.hh" # include "BKE_node_enum.hh" # include "BKE_node_runtime.hh" @@ -62,7 +63,7 @@ static void rna_NodeTreeInterfaceItem_update(Main *bmain, Scene * /*scene*/, Poi return; } ntree->tree_interface.tag_items_changed(); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } static StructRNA *rna_NodeTreeInterfaceItem_refine(PointerRNA *ptr) @@ -544,7 +545,7 @@ static bNodeTreeInterfaceSocket *rna_NodeTreeInterfaceItems_new_socket( BKE_report(reports, RPT_ERROR, "Unable to create socket"); } else { - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -570,7 +571,7 @@ static bNodeTreeInterfacePanel *rna_NodeTreeInterfaceItems_new_panel(ID *id, } else { bNodeTree *ntree = reinterpret_cast(id); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -607,7 +608,7 @@ static bNodeTreeInterfaceItem *rna_NodeTreeInterfaceItems_copy_to_parent( } else { bNodeTree *ntree = reinterpret_cast(id); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -634,7 +635,7 @@ static void rna_NodeTreeInterfaceItems_remove(ID *id, interface->remove_item(*item, move_content_to_parent); bNodeTree *ntree = reinterpret_cast(id); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -643,7 +644,7 @@ static void rna_NodeTreeInterfaceItems_clear(ID *id, bNodeTreeInterface *interfa interface->clear_items(); bNodeTree *ntree = reinterpret_cast(id); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -656,7 +657,7 @@ static void rna_NodeTreeInterfaceItems_move(ID *id, interface->move_item(*item, to_position); bNodeTree *ntree = reinterpret_cast(id); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -671,7 +672,7 @@ static void rna_NodeTreeInterfaceItems_move_to_parent(ID *id, interface->move_item_to_parent(*item, parent, to_position); bNodeTree *ntree = reinterpret_cast(id); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } diff --git a/source/blender/makesrna/intern/rna_nodetree.cc b/source/blender/makesrna/intern/rna_nodetree.cc index 760533d20b2..4f434c0ff8f 100644 --- a/source/blender/makesrna/intern/rna_nodetree.cc +++ b/source/blender/makesrna/intern/rna_nodetree.cc @@ -41,6 +41,7 @@ #include "BKE_cryptomatte.h" #include "BKE_geometry_set.hh" #include "BKE_image.hh" +#include "BKE_main_invariants.hh" #include "BKE_node.hh" #include "BKE_node_legacy_types.hh" #include "BKE_node_runtime.hh" @@ -1154,7 +1155,7 @@ static void rna_NodeTree_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr) WM_main_add_notifier(NC_NODE | NA_EDITED, &ntree->id); WM_main_add_notifier(NC_SCENE | ND_NODES, &ntree->id); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } static void rna_NodeTree_update_asset(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -1266,7 +1267,7 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, } Main *bmain = CTX_data_main(C); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); return node; @@ -1292,7 +1293,7 @@ static void rna_NodeTree_node_remove(bNodeTree *ntree, RNA_POINTER_INVALIDATE(node_ptr); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -1312,7 +1313,7 @@ static void rna_NodeTree_node_clear(bNodeTree *ntree, Main *bmain, ReportList *r node = next_node; } - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -1434,7 +1435,7 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, fromsock->flag &= ~SOCK_HIDDEN; tosock->flag &= ~SOCK_HIDDEN; - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } return ret; @@ -1459,7 +1460,7 @@ static void rna_NodeTree_link_remove(bNodeTree *ntree, blender::bke::node_remove_link(ntree, link); RNA_POINTER_INVALIDATE(link_ptr); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -1478,7 +1479,7 @@ static void rna_NodeTree_link_clear(bNodeTree *ntree, Main *bmain, ReportList *r link = next_link; } - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -1631,7 +1632,7 @@ static void rna_NodeTree_interface_update(bNodeTree *ntree, bContext *C) { Main *bmain = CTX_data_main(C); ntree->tree_interface.tag_items_changed(); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } /* ******** NodeLink ******** */ @@ -1654,7 +1655,7 @@ static void rna_NodeLink_swap_multi_input_sort_id( bNodeTree *ntree = reinterpret_cast(id); BKE_ntree_update_tag_link_changed(ntree); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -2502,7 +2503,7 @@ void rna_Node_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr) bNodeTree *ntree = reinterpret_cast(ptr->owner_id); bNode *node = static_cast(ptr->data); BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } static void rna_NodeCrop_min_x_set(PointerRNA *ptr, int value) @@ -2578,7 +2579,7 @@ void rna_Node_update_relations(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Node_socket_value_update(ID *id, bNode * /*node*/, bContext *C) { BKE_ntree_update_tag_all(reinterpret_cast(id)); - ED_node_tree_propagate_change(*CTX_data_main(C), reinterpret_cast(id)); + BKE_main_ensure_invariants(*CTX_data_main(C), *id); } static void rna_Node_select_set(PointerRNA *ptr, bool value) @@ -2684,7 +2685,7 @@ static bNodeSocket *rna_Node_inputs_new(ID *id, if (use_multi_input) { sock->flag |= SOCK_MULTI_INPUT; } - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -2722,7 +2723,7 @@ static bNodeSocket *rna_Node_outputs_new(ID *id, BKE_report(reports, RPT_ERROR, "Unable to create socket"); } else { - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -2745,7 +2746,7 @@ static void rna_Node_socket_remove( else { blender::bke::node_remove_socket(ntree, node, sock); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } } @@ -2765,7 +2766,7 @@ static void rna_Node_inputs_clear(ID *id, bNode *node, Main *bmain, ReportList * blender::bke::node_remove_socket(ntree, node, sock); } - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -2784,7 +2785,7 @@ static void rna_Node_outputs_clear(ID *id, bNode *node, Main *bmain, ReportList blender::bke::node_remove_socket(ntree, node, sock); } - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -2823,7 +2824,7 @@ static void rna_Node_inputs_move( } BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -2862,7 +2863,7 @@ static void rna_Node_outputs_move( } BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -2988,7 +2989,7 @@ static void rna_NodeInternal_update(ID *id, bNode *node, Main *bmain) { bNodeTree *ntree = reinterpret_cast(id); BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } static void rna_NodeInternal_draw_buttons(ID *id, bNode *node, bContext *C, uiLayout *layout) @@ -3123,7 +3124,7 @@ static void rna_Node_tex_image_update(Main *bmain, Scene * /*scene*/, PointerRNA bNode *node = static_cast(ptr->data); BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_IMAGE, nullptr); } @@ -3133,7 +3134,7 @@ static void rna_NodeGroup_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr bNode *node = static_cast(ptr->data); BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); DEG_relations_tag_update(bmain); } @@ -3944,7 +3945,7 @@ static bool rna_Node_pair_with_output( output_node_id = output_node->identifier; BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*CTX_data_main(C), ntree); + BKE_main_ensure_invariants(*CTX_data_main(C), ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); return true; } @@ -3976,7 +3977,7 @@ static void rna_Node_ItemArray_remove(ID *id, bNodeTree *ntree = reinterpret_cast(id); BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -3987,7 +3988,7 @@ template static void rna_Node_ItemArray_clear(ID *id, bNode * bNodeTree *ntree = reinterpret_cast(id); BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -4004,7 +4005,7 @@ static void rna_Node_ItemArray_move( bNodeTree *ntree = reinterpret_cast(id); BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -4045,7 +4046,7 @@ static void rna_Node_ItemArray_item_update(Main *bmain, Scene * /*scene*/, Point BLI_assert(node != nullptr); BKE_ntree_update_tag_node_property(&ntree, node); - ED_node_tree_propagate_change(*bmain, &ntree); + BKE_main_ensure_invariants(*bmain, ntree.id); } template @@ -4096,7 +4097,7 @@ typename Accessor::ItemT *rna_Node_ItemArray_new_with_socket_and_name( bNodeTree *ntree = reinterpret_cast(id); BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); return new_item; @@ -4109,7 +4110,7 @@ static IndexSwitchItem *rna_NodeIndexSwitchItems_new(ID *id, bNode *node, Main * bNodeTree *ntree = reinterpret_cast(id); BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); return new_item; @@ -4203,7 +4204,7 @@ static bNodeSocket *rna_NodeOutputFile_slots_new( sock = ntreeCompositOutputFileAddSocket(ntree, node, name, im_format); - ED_node_tree_propagate_change(*CTX_data_main(C), ntree); + BKE_main_ensure_invariants(*CTX_data_main(C), ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); return sock; @@ -4319,7 +4320,7 @@ static void rna_ShaderNodeScript_update(Main *bmain, Scene *scene, PointerRNA *p } BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } static void rna_ShaderNode_socket_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -4615,7 +4616,7 @@ static NodeEnumItem *rna_NodeMenuSwitchItems_new(ID *id, bNodeTree *ntree = reinterpret_cast(id); BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); return new_item; diff --git a/source/blender/makesrna/intern/rna_scene.cc b/source/blender/makesrna/intern/rna_scene.cc index 85efb19f20f..c934f2b73a8 100644 --- a/source/blender/makesrna/intern/rna_scene.cc +++ b/source/blender/makesrna/intern/rna_scene.cc @@ -40,6 +40,7 @@ #include "BKE_armature.hh" #include "BKE_editmesh.hh" #include "BKE_idtype.hh" +#include "BKE_main_invariants.hh" #include "BKE_paint.hh" #include "BKE_volume.hh" @@ -1813,7 +1814,7 @@ void rna_Scene_compositor_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr bNodeTree *ntree = reinterpret_cast(scene->nodetree); WM_main_add_notifier(NC_NODE | NA_EDITED, &ntree->id); WM_main_add_notifier(NC_SCENE | ND_NODES, &ntree->id); - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } } diff --git a/source/blender/makesrna/intern/rna_texture.cc b/source/blender/makesrna/intern/rna_texture.cc index ccd8e92aa4e..698bdbb9525 100644 --- a/source/blender/makesrna/intern/rna_texture.cc +++ b/source/blender/makesrna/intern/rna_texture.cc @@ -22,6 +22,7 @@ #include "BLI_utildefines.h" +#include "BKE_main_invariants.hh" #include "BKE_node.hh" #include "BKE_node_tree_update.hh" #include "BKE_paint.hh" @@ -194,7 +195,7 @@ static void rna_Texture_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr) } else if (GS(id->name) == ID_NT) { bNodeTree *ntree = (bNodeTree *)ptr->owner_id; - ED_node_tree_propagate_change(*bmain, ntree); + BKE_main_ensure_invariants(*bmain, ntree->id); } } diff --git a/source/blender/nodes/NOD_socket_items_ops.hh b/source/blender/nodes/NOD_socket_items_ops.hh index 1a7161ef5d3..029023490c8 100644 --- a/source/blender/nodes/NOD_socket_items_ops.hh +++ b/source/blender/nodes/NOD_socket_items_ops.hh @@ -9,6 +9,7 @@ #include "WM_api.hh" #include "BKE_context.hh" +#include "BKE_main_invariants.hh" #include "BKE_node_tree_update.hh" #include "BKE_node_tree_zones.hh" @@ -60,7 +61,7 @@ inline void update_after_node_change(bContext *C, const PointerRNA node_ptr) bNodeTree *ntree = reinterpret_cast(node_ptr.owner_id); BKE_ntree_update_tag_node_property(ntree, node); - ED_node_tree_propagate_change(*CTX_data_main(C), ntree); + BKE_main_ensure_invariants(*CTX_data_main(C), ntree->id); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); }