[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57253] trunk/blender: Fix #35640, part 2.
Lukas Toenne
lukas.toenne at googlemail.com
Wed Jun 5 21:06:33 CEST 2013
Revision: 57253
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57253
Author: lukastoenne
Date: 2013-06-05 19:06:33 +0000 (Wed, 05 Jun 2013)
Log Message:
-----------
Fix #35640, part 2. Check id.lib in poll functions for operators which do critical modification of node trees (create nodes, link, etc.). Transform operators and hide/show type operators are still
allowed, this does not modify actual behavior of the nodes and can be useful for inspecting linked nodes.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_operators/node.py
trunk/blender/source/blender/editors/include/ED_screen.h
trunk/blender/source/blender/editors/screen/screen_ops.c
trunk/blender/source/blender/editors/space_node/node_add.c
trunk/blender/source/blender/editors/space_node/node_edit.c
trunk/blender/source/blender/editors/space_node/node_group.c
trunk/blender/source/blender/editors/space_node/node_intern.h
trunk/blender/source/blender/editors/space_node/node_relationships.c
trunk/blender/source/blender/editors/transform/transform_ops.c
Modified: trunk/blender/release/scripts/startup/bl_operators/node.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/node.py 2013-06-05 19:06:27 UTC (rev 57252)
+++ trunk/blender/release/scripts/startup/bl_operators/node.py 2013-06-05 19:06:33 UTC (rev 57253)
@@ -100,7 +100,7 @@
def poll(cls, context):
space = context.space_data
# needs active node editor and a tree to add nodes to
- return (space.type == 'NODE_EDITOR' and space.edit_tree)
+ return (space.type == 'NODE_EDITOR' and space.edit_tree and not space.edit_tree.library)
# Default execute simply adds a node
def execute(self, context):
@@ -231,7 +231,7 @@
def poll(cls, context):
space = context.space_data
# needs active node editor and a tree
- return (space.type == 'NODE_EDITOR' and space.edit_tree)
+ return (space.type == 'NODE_EDITOR' and space.edit_tree and not space.edit_tree.library)
def execute(self, context):
space = context.space_data
Modified: trunk/blender/source/blender/editors/include/ED_screen.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_screen.h 2013-06-05 19:06:27 UTC (rev 57252)
+++ trunk/blender/source/blender/editors/include/ED_screen.h 2013-06-05 19:06:33 UTC (rev 57253)
@@ -142,6 +142,7 @@
int ED_operator_action_active(struct bContext *C);
int ED_operator_buttons_active(struct bContext *C);
int ED_operator_node_active(struct bContext *C);
+int ED_operator_node_editable(struct bContext *C);
int ED_operator_graphedit_active(struct bContext *C);
int ED_operator_sequencer_active(struct bContext *C);
int ED_operator_image_active(struct bContext *C);
Modified: trunk/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_ops.c 2013-06-05 19:06:27 UTC (rev 57252)
+++ trunk/blender/source/blender/editors/screen/screen_ops.c 2013-06-05 19:06:33 UTC (rev 57253)
@@ -260,6 +260,16 @@
return 0;
}
+int ED_operator_node_editable(bContext *C)
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+
+ if (snode && snode->edittree && snode->edittree->id.lib == NULL)
+ return 1;
+
+ return 0;
+}
+
/* XXX rename */
int ED_operator_graphedit_active(bContext *C)
{
Modified: trunk/blender/source/blender/editors/space_node/node_add.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_add.c 2013-06-05 19:06:27 UTC (rev 57252)
+++ trunk/blender/source/blender/editors/space_node/node_add.c 2013-06-05 19:06:33 UTC (rev 57253)
@@ -308,7 +308,7 @@
ot->exec = add_reroute_exec;
ot->cancel = WM_gesture_lines_cancel;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -416,7 +416,7 @@
/* callbacks */
ot->exec = node_add_file_exec;
ot->invoke = node_add_file_invoke;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
Modified: trunk/blender/source/blender/editors/space_node/node_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_edit.c 2013-06-05 19:06:27 UTC (rev 57252)
+++ trunk/blender/source/blender/editors/space_node/node_edit.c 2013-06-05 19:06:33 UTC (rev 57253)
@@ -318,6 +318,17 @@
return 0;
}
+/* operator poll callback */
+int composite_node_editable(bContext *C)
+{
+ if (ED_operator_node_editable(C)) {
+ SpaceNode *snode = CTX_wm_space_node(C);
+ if (ED_node_is_compositor(snode))
+ return 1;
+ }
+ return 0;
+}
+
static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup)
{
bNode *node;
@@ -1239,7 +1250,7 @@
/* api callbacks */
ot->exec = node_duplicate_exec;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1611,7 +1622,7 @@
/* callbacks */
ot->exec = node_mute_exec;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1653,7 +1664,7 @@
/* api callbacks */
ot->exec = node_delete_exec;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1696,7 +1707,7 @@
/* api callbacks */
ot->exec = node_delete_reconnect_exec;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1743,7 +1754,7 @@
/* callbacks */
ot->exec = node_output_file_add_socket_exec;
- ot->poll = composite_node_active;
+ ot->poll = composite_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1789,7 +1800,7 @@
/* callbacks */
ot->exec = node_output_file_remove_active_socket_exec;
- ot->poll = composite_node_active;
+ ot->poll = composite_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1859,7 +1870,7 @@
/* callbacks */
ot->exec = node_output_file_move_active_socket_exec;
- ot->poll = composite_node_active;
+ ot->poll = composite_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1907,7 +1918,7 @@
/* api callbacks */
ot->exec = node_copy_color_exec;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -2100,7 +2111,7 @@
/* api callbacks */
ot->exec = node_clipboard_paste_exec;
ot->invoke = node_clipboard_paste_invoke;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -2172,7 +2183,7 @@
/* api callbacks */
ot->exec = ntree_socket_add_exec;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -2218,7 +2229,7 @@
/* api callbacks */
ot->exec = ntree_socket_remove_exec;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -2286,7 +2297,7 @@
/* api callbacks */
ot->exec = ntree_socket_move_exec;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -2304,6 +2315,9 @@
bNode *node;
Text *text;
+ if (!ED_operator_node_editable(C))
+ return 0;
+
/* test if we have a render engine that supports shaders scripts */
if (!(type && type->update_script_node))
return 0;
@@ -2311,7 +2325,7 @@
/* see if we have a shader script node in context */
node = CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript).data;
- if (!node && snode && snode->edittree)
+ if (!node)
node = nodeGetActive(snode->edittree);
if (node && node->type == SH_NODE_SCRIPT) {
Modified: trunk/blender/source/blender/editors/space_node/node_group.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_group.c 2013-06-05 19:06:27 UTC (rev 57252)
+++ trunk/blender/source/blender/editors/space_node/node_group.c 2013-06-05 19:06:33 UTC (rev 57253)
@@ -71,7 +71,7 @@
static int node_group_operator_poll(bContext *C)
{
- if (ED_operator_node_active(C)) {
+ if (ED_operator_node_editable(C)) {
SpaceNode *snode = CTX_wm_space_node(C);
/* Group operators only defined for standard node tree types.
Modified: trunk/blender/source/blender/editors/space_node/node_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_intern.h 2013-06-05 19:06:27 UTC (rev 57252)
+++ trunk/blender/source/blender/editors/space_node/node_intern.h 2013-06-05 19:06:33 UTC (rev 57253)
@@ -176,6 +176,7 @@
void snode_update(struct SpaceNode *snode, struct bNode *node);
int composite_node_active(struct bContext *C);
+int composite_node_editable(struct bContext *C);
int node_has_hidden_sockets(bNode *node);
void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set);
Modified: trunk/blender/source/blender/editors/space_node/node_relationships.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_relationships.c 2013-06-05 19:06:27 UTC (rev 57252)
+++ trunk/blender/source/blender/editors/space_node/node_relationships.c 2013-06-05 19:06:33 UTC (rev 57253)
@@ -386,7 +386,7 @@
/* api callbacks */
ot->exec = node_active_link_viewer;
- ot->poll = composite_node_active;
+ ot->poll = composite_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -690,7 +690,7 @@
ot->invoke = node_link_invoke;
ot->modal = node_link_modal;
// ot->exec = node_link_exec;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
ot->cancel = node_link_cancel;
/* flags */
@@ -731,7 +731,7 @@
/* callbacks */
ot->exec = node_make_link_exec;
- ot->poll = ED_operator_node_active; // XXX we need a special poll which checks that there are selected input/output sockets
+ ot->poll = ED_operator_node_editable; // XXX we need a special poll which checks that there are selected input/output sockets
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -826,7 +826,7 @@
ot->exec = cut_links_exec;
ot->cancel = WM_gesture_lines_cancel;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -868,7 +868,7 @@
ot->description = "Remove all links to selected nodes, and try to connect neighbor nodes together";
ot->exec = detach_links_exec;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -937,7 +937,7 @@
/* api callbacks */
ot->exec = node_parent_set_exec;
- ot->poll = ED_operator_node_active;
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -971,7 +971,7 @@
/* api callbacks */
ot->exec = node_parent_clear_exec;
- ot->poll = ED_operator_node_active;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list