diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-04-03 13:10:29 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-04-03 13:10:29 +0400 |
commit | bb4ab6a007ddc1130cc80439c9d4cd89c8117fb6 (patch) | |
tree | c24bd2e13e6a85992879df33d8f53996e9d87a9e /source/blender/editors/space_node/node_edit.c | |
parent | bfeef2f5f07094c4014ce7c7bf7e933c168c2bd0 (diff) |
Fix #33628, Segmentation fault after pasting a closed group of nodes into an open group. Finally now there is a proper check for pasting nodes into groups. It uses the poll_instance callback of node types to determine if a node can be added into a specific node tree. Currently this is only implemented for group nodes and does a recursive check to avoid pasting a node group into itself (on any level, also nested groups).
Diffstat (limited to 'source/blender/editors/space_node/node_edit.c')
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index cba807a436f..5faafe7bdce 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1978,7 +1978,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) bNodeLink *link; int num_nodes; float center[2]; - int is_clipboard_valid; + int is_clipboard_valid, all_nodes_valid; /* validate pointers in the clipboard */ is_clipboard_valid = BKE_node_clipboard_validate(); @@ -2000,6 +2000,17 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Some nodes references could not be restored, will be left empty"); } + /* make sure all clipboard nodes would be valid in the target tree */ + all_nodes_valid = TRUE; + for (node = clipboard_nodes_lb->first; node; node = node->next) { + if (!node->typeinfo->poll_instance(node, ntree)) { + all_nodes_valid = FALSE; + BKE_reportf(op->reports, RPT_ERROR, "Cannot add node %s into node tree %s", node->name, ntree->id.name+2); + } + } + if (!all_nodes_valid) + return OPERATOR_CANCELLED; + ED_preview_kill_jobs(C); /* deselect old nodes */ |