aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-06-29 04:48:42 +0200
committerSven Gothel <[email protected]>2023-06-29 04:48:42 +0200
commit4e9d0edc3810d36ffe1660e6ac17d1dc547ea7d7 (patch)
treeb924d23c4c3ca42795e89f2e43f8e38743fd69ca /src/java/com
parent0298341f71f43f4011a40e955bd5e99cbd798597 (diff)
GlueGen JavaCallback: Set-Callback: Ensure a previously mapped 'userParam' instance is released before binding new one; Add test changing callback function.
Diffstat (limited to 'src/java/com')
-rw-r--r--src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
index 1469b4f..047a637 100644
--- a/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
@@ -622,6 +622,8 @@ public class JavaMethodBindingEmitter extends FunctionEmitter {
boolean needsResultAssignment = false;
if( null != javaCallback ) {
+ final String userParamArgName = binding.getArgumentName(javaCallback.setFuncUserParamIdx);
+ unit.emitln(" release"+getInterfaceName()+"("+userParamArgName+"); // Ensure a previously mapped instance is released");
unit.emitln(" final long[] nativeUserParam = { 0 };");
}
if (!returnType.isVoid()) {
@@ -658,9 +660,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter {
final String funcArgName = binding.getArgumentName(javaCallback.setFuncCBParamIdx);
final String userParamArgName = binding.getArgumentName(javaCallback.setFuncUserParamIdx);
// unit.emitln(" System.err.println(\"ZZZ returned nativeUserParam \"+nativeUserParam[0]);");
- unit.emitln(" if( 0 == nativeUserParam[0] ) {");
- unit.emitln(" release"+getInterfaceName()+"("+userParamArgName+");");
- unit.emitln(" } else {");
+ unit.emitln(" if( 0 != nativeUserParam[0] ) {");
unit.emitln(" "+javaCallback.cbFuncTypeName+"UsrMap.put("+userParamArgName+", new "+javaCallback.cbFuncTypeName+"UserParam("+funcArgName+", "+userParamArgName+", nativeUserParam[0]));");
unit.emitln(" }");
}