Commit: 2f2d13b8c664b90a7d3249d6ad71bac3d519026d Author: Jacques Lucke Date: Mon May 23 14:43:12 2022 +0200 Branches: blender-v3.2-release https://developer.blender.org/rB2f2d13b8c664b90a7d3249d6ad71bac3d519026d
Fix T97237: dragging custom node group asset adds broken node Differential Revision: https://developer.blender.org/D15013 =================================================================== M source/blender/editors/space_node/node_add.cc =================================================================== diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index 7fb15d69ab5..e753ed6eb03 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -348,8 +348,14 @@ static int node_add_group_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); + const char *node_idname = node_group_idname(C); + if (node_idname[0] == '\0') { + BKE_report(op->reports, RPT_WARNING, "Could not determine type of group node"); + return OPERATOR_CANCELLED; + } + bNode *group_node = node_add_node(*C, - node_group_idname(C), + node_idname, (node_group->type == NTREE_CUSTOM) ? NODE_CUSTOM_GROUP : NODE_GROUP, snode->runtime->cursor[0], @@ -368,6 +374,21 @@ static int node_add_group_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static bool node_add_group_poll(bContext *C) +{ + if (!ED_operator_node_editable(C)) { + return false; + } + const SpaceNode *snode = CTX_wm_space_node(C); + if (snode->edittree->type == NTREE_CUSTOM) { + CTX_wm_operator_poll_msg_set(C, + "This node editor displays a custom (Python defined) node tree. " + "Dropping node groups isn't supported for this."); + return false; + } + return true; +} + static int node_add_group_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *region = CTX_wm_region(C); @@ -396,7 +417,7 @@ void NODE_OT_add_group(wmOperatorType *ot) /* callbacks */ ot->exec = node_add_group_exec; ot->invoke = node_add_group_invoke; - ot->poll = ED_operator_node_editable; + ot->poll = node_add_group_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
