Remove mutex lock from node localization
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 6 Jun 2019 08:39:44 +0000 (10:39 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 6 Jun 2019 08:39:44 +0000 (10:39 +0200)
There is no obvious threading-unsafe code in the localization.
The main source of issues were the new_node/new_socket pointers
which are no longer used during node tree duplication.

source/blender/blenkernel/intern/node.c
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_node_types.h

index 6ff0bb9..e1f7a34 100644 (file)
@@ -322,7 +322,6 @@ void ntreeSetTypes(const struct bContext *C, bNodeTree *ntree)
 static GHash *nodetreetypes_hash = NULL;
 static GHash *nodetypes_hash = NULL;
 static GHash *nodesockettypes_hash = NULL;
-static SpinLock spin;
 
 bNodeTreeType *ntreeTypeFind(const char *idname)
 {
@@ -1426,8 +1425,6 @@ void BKE_node_tree_copy_data(Main *UNUSED(bmain),
   /* in case a running nodetree is copied */
   ntree_dst->execdata = NULL;
 
-  ntree_dst->duplilock = NULL;
-
   BLI_listbase_clear(&ntree_dst->nodes);
   BLI_listbase_clear(&ntree_dst->links);
 
@@ -2046,10 +2043,6 @@ void ntreeFreeTree(bNodeTree *ntree)
     BKE_node_instance_hash_free(ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free);
   }
 
-  if (ntree->duplilock) {
-    BLI_mutex_free(ntree->duplilock);
-  }
-
   if (ntree->id.tag & LIB_TAG_LOCALIZED) {
     BKE_libblock_free_data(&ntree->id, true);
   }
@@ -2227,14 +2220,6 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
     bNodeTree *ltree;
     bNode *node;
 
-    BLI_spin_lock(&spin);
-    if (!ntree->duplilock) {
-      ntree->duplilock = BLI_mutex_alloc();
-    }
-    BLI_spin_unlock(&spin);
-
-    BLI_mutex_lock(ntree->duplilock);
-
     /* Make full copy outside of Main database.
      * Note: previews are not copied here.
      */
@@ -2264,8 +2249,6 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
       ntree->typeinfo->localize(ltree, ntree);
     }
 
-    BLI_mutex_unlock(ntree->duplilock);
-
     return ltree;
   }
   else {
@@ -3978,7 +3961,6 @@ void init_nodesystem(void)
   nodetreetypes_hash = BLI_ghash_str_new("nodetreetypes_hash gh");
   nodetypes_hash = BLI_ghash_str_new("nodetypes_hash gh");
   nodesockettypes_hash = BLI_ghash_str_new("nodesockettypes_hash gh");
-  BLI_spin_init(&spin);
 
   register_undefined_types();
 
index a4bdf02..6ea6198 100644 (file)
@@ -3482,7 +3482,6 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
 
   ntree->progress = NULL;
   ntree->execdata = NULL;
-  ntree->duplilock = NULL;
 
   ntree->adt = newdataadr(fd, ntree->adt);
   direct_link_animdata(fd, ntree->adt);
index 342641f..672dbae 100644 (file)
@@ -479,9 +479,6 @@ typedef struct bNodeTree {
   int (*test_break)(void *);
   void (*update_draw)(void *);
   void *tbh, *prh, *sdh, *udh;
-
-  void *duplilock;
-
 } bNodeTree;
 
 /* ntree->type, index */