Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-06-20 13:16:16 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-06-20 13:27:26 +0300
commitfd48e685c3077b781d8b81b8d5048c49d2ad5091 (patch)
treeb6323c562ddac40bfb0f00ae3307a8fa9cf21368 /source/blender
parentd4519f54b30171ee3a0e38901ffb291ab4d87cae (diff)
Cleanup: remove some G.main from BKE's node.c
Validate some cases using G_MAIN instead (I don't think we want to work on any other Main than G.main one when registering/unregistering nodes etc.). And when freeing, all ID not in Main shall now be tagged accordingly, so we *should* not need to do that stupi search over all ntrees in G.main to check wether we have to free it ourself or not!
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/node.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index b90e2d70e05..5b279de4d8f 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -312,7 +312,9 @@ void ntreeTypeAdd(bNodeTreeType *nt)
{
BLI_ghash_insert(nodetreetypes_hash, nt->idname, nt);
/* XXX pass Main to register function? */
- update_typeinfo(G.main, NULL, nt, NULL, NULL, false);
+ /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
+ * active Mains, which we cannot do anyway currently. */
+ update_typeinfo(G_MAIN, NULL, nt, NULL, NULL, false);
}
/* callback for hash value free function */
@@ -320,7 +322,9 @@ static void ntree_free_type(void *treetype_v)
{
bNodeTreeType *treetype = treetype_v;
/* XXX pass Main to unregister function? */
- update_typeinfo(G.main, NULL, treetype, NULL, NULL, true);
+ /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
+ * active Mains, which we cannot do anyway currently. */
+ update_typeinfo(G_MAIN, NULL, treetype, NULL, NULL, true);
MEM_freeN(treetype);
}
@@ -369,7 +373,9 @@ static void node_free_type(void *nodetype_v)
{
bNodeType *nodetype = nodetype_v;
/* XXX pass Main to unregister function? */
- update_typeinfo(G.main, NULL, NULL, nodetype, NULL, true);
+ /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
+ * active Mains, which we cannot do anyway currently. */
+ update_typeinfo(G_MAIN, NULL, NULL, nodetype, NULL, true);
/* XXX deprecated */
if (nodetype->type == NODE_DYNAMIC)
@@ -387,7 +393,9 @@ void nodeRegisterType(bNodeType *nt)
BLI_ghash_insert(nodetypes_hash, nt->idname, nt);
/* XXX pass Main to register function? */
- update_typeinfo(G.main, NULL, NULL, nt, NULL, false);
+ /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
+ * active Mains, which we cannot do anyway currently. */
+ update_typeinfo(G_MAIN, NULL, NULL, nt, NULL, false);
}
void nodeUnregisterType(bNodeType *nt)
@@ -423,7 +431,9 @@ static void node_free_socket_type(void *socktype_v)
{
bNodeSocketType *socktype = socktype_v;
/* XXX pass Main to unregister function? */
- update_typeinfo(G.main, NULL, NULL, NULL, socktype, true);
+ /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
+ * active Mains, which we cannot do anyway currently. */
+ update_typeinfo(G_MAIN, NULL, NULL, NULL, socktype, true);
MEM_freeN(socktype);
}
@@ -432,7 +442,9 @@ void nodeRegisterSocketType(bNodeSocketType *st)
{
BLI_ghash_insert(nodesockettypes_hash, (void *)st->idname, st);
/* XXX pass Main to register function? */
- update_typeinfo(G.main, NULL, NULL, NULL, st, false);
+ /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
+ * active Mains, which we cannot do anyway currently. */
+ update_typeinfo(G_MAIN, NULL, NULL, NULL, st, false);
}
void nodeUnregisterSocketType(bNodeSocketType *st)
@@ -1787,7 +1799,6 @@ static void free_localized_node_groups(bNodeTree *ntree)
/** Free (or release) any data used by this nodetree (does not free the nodetree itself). */
void ntreeFreeTree(bNodeTree *ntree)
{
- bNodeTree *tntree;
bNode *node, *next;
bNodeSocket *sock, *nextsock;
@@ -1844,10 +1855,7 @@ void ntreeFreeTree(bNodeTree *ntree)
BLI_mutex_free(ntree->duplilock);
/* if ntree is not part of library, free the libblock data explicitly */
- for (tntree = G.main->nodetree.first; tntree; tntree = tntree->id.next)
- if (tntree == ntree)
- break;
- if (tntree == NULL) {
+ if (ntree->id.tag & LIB_TAG_NO_MAIN) {
BKE_libblock_free_data(&ntree->id, true);
}
}
@@ -2623,7 +2631,8 @@ bool BKE_node_clipboard_validate(void)
/* currently only validate the ID */
if (node->id) {
- ListBase *lb = which_libbase(G.main, GS(node_info->id_name));
+ /* We want to search into current blend file, so using G_MAIN is valid here too. */
+ ListBase *lb = which_libbase(G_MAIN, GS(node_info->id_name));
BLI_assert(lb != NULL);
if (BLI_findindex(lb, node_info->id) == -1) {