[Bf-blender-cvs] [baf585c] object_nodes: Retain functions both for storage in the cache as well as keeping the pointer during eval.

Lukas Tönne noreply at git.blender.org
Tue Apr 5 11:06:03 CEST 2016


Commit: baf585cdc529366fc2542a3b163c1d5a09c640c7
Author: Lukas Tönne
Date:   Tue Apr 5 11:04:44 2016 +0200
Branches: object_nodes
https://developer.blender.org/rBbaf585cdc529366fc2542a3b163c1d5a09c640c7

Retain functions both for storage in the cache as well as keeping the pointer during eval.

Otherwise the function is freed immediately after each use, making the cache pointless.

===================================================================

M	source/blender/blenvm/intern/bvm_api.cc
M	source/blender/blenvm/intern/function_cache.cc

===================================================================

diff --git a/source/blender/blenvm/intern/bvm_api.cc b/source/blender/blenvm/intern/bvm_api.cc
index 36b7367..b89cbc9 100644
--- a/source/blender/blenvm/intern/bvm_api.cc
+++ b/source/blender/blenvm/intern/bvm_api.cc
@@ -98,7 +98,9 @@ void BVM_free(void)
 	using namespace blenvm;
 	
 	blenvm::function_bvm_cache_clear();
+#ifdef WITH_LLVM
 	blenvm::function_llvm_cache_clear();
+#endif
 	
 	nodes_free();
 	
@@ -435,6 +437,8 @@ struct BVMFunction *BVM_gen_forcefield_function_bvm(bNodeTree *btree, bool use_c
 		}
 	}
 	
+	fn->retain(fn);
+	
 	bvm_lock.unlock();
 	
 	return (BVMFunction *)fn;
@@ -1019,6 +1023,8 @@ struct BVMFunction *BVM_gen_texture_function_bvm(bNodeTree *btree, bool use_cach
 		}
 	}
 	
+	fn->retain(fn);
+	
 	bvm_lock.unlock();
 	
 	return (BVMFunction *)fn;
@@ -1050,6 +1056,8 @@ struct BVMFunction *BVM_gen_texture_function_llvm(bNodeTree *btree, bool use_cac
 		}
 	}
 	
+	fn->retain(fn);
+	
 	llvm_lock.unlock();
 	
 	return (BVMFunction *)fn;
@@ -1163,6 +1171,8 @@ struct BVMFunction *BVM_gen_modifier_function_bvm(struct bNodeTree *btree, bool
 		}
 	}
 	
+	fn->retain(fn);
+	
 	bvm_lock.unlock();
 	
 	return (BVMFunction *)fn;
@@ -1251,6 +1261,8 @@ struct BVMFunction *BVM_gen_dupli_function_bvm(struct bNodeTree *btree, bool use
 		}
 	}
 	
+	fn->retain(fn);
+	
 	bvm_lock.unlock();
 	
 	return (BVMFunction *)fn;
diff --git a/source/blender/blenvm/intern/function_cache.cc b/source/blender/blenvm/intern/function_cache.cc
index 840d9c7..82760e0 100644
--- a/source/blender/blenvm/intern/function_cache.cc
+++ b/source/blender/blenvm/intern/function_cache.cc
@@ -53,7 +53,6 @@ struct FunctionCache {
 		function_type *fn = NULL;
 		if (it != m_functions.end()) {
 			fn = it->second;
-			function_type::retain(fn);
 		}
 		return fn;
 	}




More information about the Bf-blender-cvs mailing list