From df81b50bf2b250e09faae0af469e676203a4ff3e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 6 Aug 2012 08:41:45 +0000 Subject: prevent copy/paste from incompatible types (compo -> material for eg) - would crash instantly. --- source/blender/editors/space_node/node_edit.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index acbf0f09cc5..68806a802ac 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -46,9 +46,10 @@ #include "BKE_image.h" #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_node.h" #include "BKE_material.h" +#include "BKE_node.h" #include "BKE_paint.h" +#include "BKE_report.h" #include "BKE_scene.h" #include "BKE_texture.h" @@ -1918,6 +1919,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op)) /* clear current clipboard */ BKE_node_clipboard_clear(); + BKE_node_clipboard_init(ntree); /* get group node offset */ if (gnode) @@ -1992,7 +1994,7 @@ void NODE_OT_clipboard_copy(wmOperatorType *ot) /* ****************** Paste from clipboard ******************* */ -static int node_clipboard_paste_exec(bContext *C, wmOperator *UNUSED(op)) +static int node_clipboard_paste_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = snode->edittree; @@ -2003,6 +2005,11 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *UNUSED(op)) int num_nodes; float centerx, centery; + if (BKE_node_clipboard_get_type() != ntree->type) { + BKE_report(op->reports, RPT_ERROR, "Clipboard nodes are an incompatible type"); + return OPERATOR_CANCELLED; + } + ED_preview_kill_jobs(C); /* deselect old nodes */ -- cgit v1.2.3