[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12976] branches/pynodes/source/blender: Another small update / fix, this one for reparsing a failed pynode' s script when the user presses the "update" button.
Willian Padovani Germano
wpgermano at gmail.com
Sat Dec 22 22:11:27 CET 2007
Revision: 12976
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12976
Author: ianwill
Date: 2007-12-22 22:11:27 +0100 (Sat, 22 Dec 2007)
Log Message:
-----------
Another small update / fix, this one for reparsing a failed pynode's script when the user presses the "update" button.
Modified Paths:
--------------
branches/pynodes/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
branches/pynodes/source/blender/src/drawnode.c
Modified: branches/pynodes/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
===================================================================
--- branches/pynodes/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c 2007-12-22 17:16:06 UTC (rev 12975)
+++ branches/pynodes/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c 2007-12-22 21:11:27 UTC (rev 12976)
@@ -108,6 +108,7 @@
if (tinfo->name) MEM_freeN(tinfo->name);
MEM_freeN(tinfo);
+ node->typeinfo = NULL;
}
static void node_dynamic_free_sockets(bNode *node)
@@ -158,7 +159,7 @@
{
node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_LOADED);
node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_ADDEXIST);
- node->custom1 = BSET(node->custom1, NODE_DYNAMIC_NEW);
+ //node->custom1 = BSET(node->custom1, NODE_DYNAMIC_NEW);
node->custom1 = BSET(node->custom1, NODE_DYNAMIC_ERROR);
node_dynamic_free_typeinfo_sockets(node);
@@ -192,14 +193,20 @@
if (!node->id)
return;
- /* READY or ERROR, no need to be here */
- if (BTST2(node->custom1, NODE_DYNAMIC_READY, NODE_DYNAMIC_ERROR))
+ /* READY, no need to be here */
+ if (BTST(node->custom1, NODE_DYNAMIC_READY))
return;
if (BTST(node->custom1, NODE_DYNAMIC_REPARSE)) {
- node_dynamic_free_typeinfo_sockets(node);
- node_dynamic_update_socket_links(node);
- node_dynamic_free_storage(node);
+ if (BTST(node->custom1, NODE_DYNAMIC_ERROR)) {
+ nodeMakeDynamicType(node);
+ node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_ERROR);
+ node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_REPARSE);
+ } else {
+ node_dynamic_free_typeinfo_sockets(node);
+ node_dynamic_update_socket_links(node);
+ node_dynamic_free_storage(node);
+ }
nsd = MEM_callocN(sizeof(NodeScriptDict), "node script dictionary");
nsd->dict = init_dynamicdict();
node->storage = nsd;
@@ -208,6 +215,9 @@
return;
}
+ if (BTST(node->custom1, NODE_DYNAMIC_ERROR))
+ return;
+
if (node->storage)
printf("\nPYNODES ERROR: has node storage in node_dynamic_setup\n");
@@ -312,14 +322,17 @@
if (!node->id)
return;
- if(BTST(node->custom1, NODE_DYNAMIC_ERROR))
- return;
+ if(BTST(node->custom1, NODE_DYNAMIC_ERROR)) {
+ if(BNTST(node->custom1, NODE_DYNAMIC_REPARSE))
+ return;
+ }
if(BTST2(node->custom1, NODE_DYNAMIC_NEW, NODE_DYNAMIC_REPARSE)) {
node_dynamic_setup(node);
return;
}
+ /* XXX NODE_DYNAMIC_UPDATED: unused? remove? */
if(BTST2(node->custom1, NODE_DYNAMIC_READY, NODE_DYNAMIC_UPDATED)) {
if(BTST(node->custom1,NODE_DYNAMIC_UPDATED)) {
node->custom1= BCLR(node->custom1,NODE_DYNAMIC_UPDATED);
@@ -354,9 +367,9 @@
PyObject *value= NULL;
PyObject *testinst= NULL;
PyObject *args= NULL;
- NodeScriptDict *nsd= NULL;
+ NodeScriptDict *nsd = NULL;
PyObject *pyresult = NULL;
- char *buf= NULL;
+ char *buf = NULL;
int pos = 0, is_valid_script = 0;
if (!node->id || !node->storage)
@@ -418,14 +431,11 @@
nodeRegisterType(&node_all_shaders, node->typeinfo);
MEM_freeN(node->typeinfo); /* nodeRegisterType copied it to a new one */
node->typeinfo = node_dynamic_find_typeinfo(&node_all_shaders, node->id);
- } // else
- //node_dynamic_update_script_links(node->id);
- node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_NEW);
- node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_LOADED);
- node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_REPARSE);
+ }
+ node->custom1 = 0;
}
- node->custom1= BSET(node->custom1, NODE_DYNAMIC_READY);
+ node->custom1 = BSET(node->custom1, NODE_DYNAMIC_READY);
break;
}
Py_DECREF(args);
Modified: branches/pynodes/source/blender/src/drawnode.c
===================================================================
--- branches/pynodes/source/blender/src/drawnode.c 2007-12-22 17:16:06 UTC (rev 12975)
+++ branches/pynodes/source/blender/src/drawnode.c 2007-12-22 21:11:27 UTC (rev 12976)
@@ -434,10 +434,16 @@
{
bNode *node= (bNode *)node_v;
/*bNodeTree *ntree= (bNodeTree *)ntree_v;*/
+ int error = 0;
+ if (BTST(node->custom1, NODE_DYNAMIC_ERROR)) error = 1;
+
node->custom1= 0;
node->custom1= BSET(node->custom1, NODE_DYNAMIC_REPARSE);
-
+
+ if (error)
+ node->custom1= BSET(node->custom1, NODE_DYNAMIC_ERROR);
+
/*nodeDynamicParse(node);
if(node->custom1== SH_NODE_DYNAMIC_CREATED)
nodeAddSockets(node, node->typeinfo);
@@ -745,14 +751,15 @@
static int node_shader_buts_dynamic(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
- if(block) {
+ if (block) {
uiBut *bt;
+ SpaceNode *snode= curarea->spacedata.first;
//short dx= (short)((butr->xmax-butr->xmin)/3.0f), has_us= (node->id && node->id->us>1);
short dy= (short)butr->ymin;
int xoff=0;
/* B_NODE_EXEC is handled in butspace.c do_node_buts */
- if(node->id==NULL) {
+ if(!node->id) {
char *strp;
IDnames_to_pupstring(&strp, NULL, "", &(G.main->text), NULL, NULL);
node->menunr= 0;
@@ -762,14 +769,20 @@
uiButSetFunc(bt, node_browse_text_cb, ntree, node);
xoff=19;
if(strp) MEM_freeN(strp);
- }
- if(node->id) {
+ }
+ else {
bt = uiDefBut(block, BUT, B_NOP, "Update",
butr->xmin+xoff, butr->ymin+20, 50, 19,
&node->menunr, 0.0, 19.0, 0, 0, "Refresh this node (and all others that use the same script)");
uiButSetFunc(bt, node_dynamic_update_cb, ntree, node);
+
+ if (BTST(node->custom1, NODE_DYNAMIC_ERROR)) {
+ BIF_ThemeColor(TH_REDALERT);
+ ui_rasterpos_safe(butr->xmin + xoff, butr->ymin + 5, snode->aspect);
+ snode_drawstring(snode, "Error! Check console...", butr->xmax - butr->xmin);
+ }
}
- }
+ }
return 20+19;
}
More information about the Bf-blender-cvs
mailing list