From 4e9d0edc3810d36ffe1660e6ac17d1dc547ea7d7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 29 Jun 2023 04:48:42 +0200 Subject: GlueGen JavaCallback: Set-Callback: Ensure a previously mapped 'userParam' instance is released before binding new one; Add test changing callback function. --- src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/java/com/jogamp/gluegen') 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(" }"); } -- cgit v1.2.3