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
path: root/source
diff options
context:
space:
mode:
authorGermano Cavalcante <mano-wii>2022-09-14 14:42:57 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2022-09-14 15:13:12 +0300
commit4e4daa641764fcd5fe54edb98d3e4bec47480992 (patch)
tree7755737c111a0f29a78341883734aa7b809f1cee /source
parent10a3bfa5ee81524e438206ae6b2720466b9b2883 (diff)
Fix T100959: Memory leak when moving node with Alt
The memory leak happens because `ED_node_link_insert` (called after the transform operation) overwrites the pre-existing `snode->runtime->iofsd`, losing the reference without freeing the memory. So to "move" the reference from `snode->runtime->iofsd` to `op->customdata`, so that each operator works with its own data. Reviewed By: Severin Differential Revision: https://developer.blender.org/D15948
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_node/node_relationships.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc
index 929fb64bd70..e12ab3191cb 100644
--- a/source/blender/editors/space_node/node_relationships.cc
+++ b/source/blender/editors/space_node/node_relationships.cc
@@ -2312,10 +2312,10 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd,
/**
* Modal handler for insert offset animation
*/
-static int node_insert_offset_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+static int node_insert_offset_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
SpaceNode *snode = CTX_wm_space_node(C);
- NodeInsertOfsData *iofsd = snode->runtime->iofsd;
+ NodeInsertOfsData *iofsd = static_cast<NodeInsertOfsData *>(op->customdata);
bool redraw = false;
if (!snode || event->type != TIMER || iofsd == nullptr ||
@@ -2355,7 +2355,6 @@ static int node_insert_offset_modal(bContext *C, wmOperator *UNUSED(op), const w
node->anim_init_locx = node->anim_ofsx = 0.0f;
}
- snode->runtime->iofsd = nullptr;
MEM_freeN(iofsd);
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
@@ -2370,6 +2369,8 @@ static int node_insert_offset_invoke(bContext *C, wmOperator *op, const wmEvent
{
const SpaceNode *snode = CTX_wm_space_node(C);
NodeInsertOfsData *iofsd = snode->runtime->iofsd;
+ snode->runtime->iofsd = nullptr;
+ op->customdata = iofsd;
if (!iofsd || !iofsd->insert) {
return OPERATOR_CANCELLED;
@@ -2476,6 +2477,7 @@ void ED_node_link_insert(Main *bmain, ScrArea *area)
/* Set up insert offset data, it needs stuff from here. */
if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) {
+ BLI_assert(snode->runtime->iofsd == nullptr);
NodeInsertOfsData *iofsd = MEM_cnew<NodeInsertOfsData>(__func__);
iofsd->insert = node_to_insert;