From 33729eaf69c3220ebf791b9260bfca1bb3c5048a Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 8 Nov 2021 16:52:30 +0100 Subject: improve behavior --- .../editors/space_node/node_relationships.cc | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index 14a0941bd2e..620821c708f 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -1709,25 +1709,39 @@ static int make_link_portals_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(CTX_wm_manager(C), bmain); - bool changed_link = false; + blender::Vector intersecting_links; LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) { if (node_link_is_hidden_or_dimmed(®ion->v2d, link)) { continue; } if (node_links_intersect(link, coords, tot_coords)) { - if (link->flag & NODE_LINK_PORTAL) { - link->flag &= ~NODE_LINK_PORTAL; - } - else { - link->flag |= NODE_LINK_PORTAL; - } - changed_link = true; + intersecting_links.append(link); } } - if (!changed_link) { + if (intersecting_links.is_empty()) { return OPERATOR_CANCELLED; } + + bool any_link_is_portal = false; + for (bNodeLink *link : intersecting_links) { + if (nodeLinkIsPortal(link)) { + any_link_is_portal = true; + break; + } + } + + if (any_link_is_portal) { + for (bNodeLink *link : intersecting_links) { + link->flag &= ~NODE_LINK_PORTAL; + } + } + else { + for (bNodeLink *link : intersecting_links) { + link->flag |= NODE_LINK_PORTAL; + } + } + snode_notify(C, snode); return OPERATOR_FINISHED; } -- cgit v1.2.3