diff options
author | Ton Roosendaal <ton@blender.org> | 2007-03-26 19:07:38 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2007-03-26 19:07:38 +0400 |
commit | 5c760e481114da07ef2ee364bc305bb7716abe8c (patch) | |
tree | 623d328cfd9383efb051d197e6264af185cf1e37 /source/blender/src | |
parent | d1315a342d7db1653a7fc3cecb646ab785e08f6e (diff) |
Changed node type definitions to use a dynamic list.
This will allow python or plugin defined nodes to work as well.
(And fixes compile issues with MSVC in yesterdays commit for nodes)
Code provided by Nathan L.
Fixes in his code:
- free_nodesystem() was called too late (after guarded alloc was closed)
- free_nodesystem() was freeing nodes that were not malloced even
- free_nodesystem was using free, not freeN :)
- the typedefs needed to be malloced yes, to allow duplicate nodes like
group but also for dynamic nodes.
Diffstat (limited to 'source/blender/src')
-rw-r--r-- | source/blender/src/drawnode.c | 18 | ||||
-rw-r--r-- | source/blender/src/header_node.c | 17 | ||||
-rw-r--r-- | source/blender/src/toolbox.c | 20 | ||||
-rw-r--r-- | source/blender/src/usiblender.c | 7 |
4 files changed, 37 insertions, 25 deletions
diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c index 7978640039f..7faa4ecc76f 100644 --- a/source/blender/src/drawnode.c +++ b/source/blender/src/drawnode.c @@ -1621,19 +1621,19 @@ static void node_composit_set_butfunc(bNodeType *ntype) void init_node_butfuncs(void) { - bNodeType **typedefs; + bNodeType *ntype; /* shader nodes */ - typedefs= node_all_shaders; /* BKE_node.h */ - while( *typedefs) { - node_shader_set_butfunc(*typedefs); - typedefs++; + ntype= node_all_shaders.first; + while(ntype) { + node_shader_set_butfunc(ntype); + ntype= ntype->next; } /* composit nodes */ - typedefs= node_all_composit; /* BKE_node.h */ - while( *typedefs) { - node_composit_set_butfunc(*typedefs); - typedefs++; + ntype= node_all_composit.first; + while(ntype) { + node_composit_set_butfunc(ntype); + ntype= ntype->next; } } diff --git a/source/blender/src/header_node.c b/source/blender/src/header_node.c index 2697cb0c39b..b9f02cc7bd0 100644 --- a/source/blender/src/header_node.c +++ b/source/blender/src/header_node.c @@ -247,9 +247,12 @@ static void node_make_addmenu(SpaceNode *snode, int nodeclass, uiBlock *block) tot++; } else { - for(typedefs= ntree->alltypes; *typedefs; typedefs++) - if( (*typedefs)->nclass == nodeclass ) + bNodeType *type = ntree->alltypes.first; + while(type) { + if(type->nclass == nodeclass) tot++; + type= type->next; + } } } @@ -270,10 +273,12 @@ static void node_make_addmenu(SpaceNode *snode, int nodeclass, uiBlock *block) } } else { - for(a=0, typedefs= ntree->alltypes; *typedefs; typedefs++) { - if( (*typedefs)->nclass == nodeclass ) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, (*typedefs)->name, 0, - yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, (*typedefs)->type, ""); + bNodeType *type; + for(a=0, type= ntree->alltypes.first; type; type=type->next) { + if( type->nclass == nodeclass ) { + printf("node %s\n", type->name); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, type->name, 0, + yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, type->type, ""); a++; } } diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c index a200e8d44eb..3143b9652aa 100644 --- a/source/blender/src/toolbox.c +++ b/source/blender/src/toolbox.c @@ -1576,7 +1576,6 @@ static TBitem *node_add_sublevel(ListBase *storage, bNodeTree *ntree, int nodecl { static TBitem _addmenu[]= { { 0, " ", 0, NULL}, { -1, "", 0, NULL}}; Link *link; - bNodeType **typedefs; TBitem *addmenu; int tot= 0, a; @@ -1588,9 +1587,13 @@ static TBitem *node_add_sublevel(ListBase *storage, bNodeTree *ntree, int nodecl tot++; } else { - for(typedefs= ntree->alltypes; *typedefs; typedefs++) - if( (*typedefs)->nclass == nodeclass ) + bNodeType *ntype = ntree->alltypes.first; + while(ntype) { + if(ntype->nclass == nodeclass) { tot++; + } + ntype= ntype->next; + } } } if(tot==0) { @@ -1612,15 +1615,16 @@ static TBitem *node_add_sublevel(ListBase *storage, bNodeTree *ntree, int nodecl } } else { - for(a=0, typedefs= ntree->alltypes; *typedefs; typedefs++) { - if( (*typedefs)->nclass == nodeclass ) { - addmenu[a].name= (*typedefs)->name; - addmenu[a].retval= (*typedefs)->type; + bNodeType *ntype= ntree->alltypes.first; + for(a=0; ntype; ntype= ntype->next) { + if( ntype->nclass == nodeclass ) { + addmenu[a].name= ntype->name; + addmenu[a].retval= ntype->type; a++; } } } - + addmenu[a].icon= -1; /* end signal */ addmenu[a].name= ""; addmenu[a].retval= a; diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c index b81cba7d1d0..d8106b8d3d6 100644 --- a/source/blender/src/usiblender.c +++ b/source/blender/src/usiblender.c @@ -79,6 +79,7 @@ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_mball.h" +#include "BKE_node.h" #include "BKE_packedFile.h" #include "BKE_utildefines.h" @@ -967,7 +968,9 @@ void exit_usiblender(void) BLI_freelistN(&U.themes); BIF_preview_free_dbase(); - + + free_nodesystem(); + if(totblock!=0) { printf("Error Totblock: %d\n",totblock); MEM_printmemlist(); @@ -986,6 +989,6 @@ void exit_usiblender(void) SYS_DeleteSystem(SYS_GetSystem()); - + exit(G.afbreek==1); } |