From 08fe29a8696a2c77c1d24a637dfb54af2537afe7 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Wed, 9 Feb 2011 18:16:23 +0100 Subject: fixed NPE in CLContext.release() which was indroduced in last commit. --- src/com/jogamp/opencl/CLContext.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/com/jogamp/opencl') diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java index b7ddb813..240f6d00 100644 --- a/src/com/jogamp/opencl/CLContext.java +++ b/src/com/jogamp/opencl/CLContext.java @@ -483,9 +483,11 @@ public class CLContext extends CLObject implements CLResource { private void release(Collection resources) { // resources remove themselves when released, see above - CLResource[] array = resources.toArray(new CLResource[resources.size()]); - for (CLResource resource : array) { - resource.release(); + if(!resources.isEmpty()) { + CLResource[] array = resources.toArray(new CLResource[resources.size()]); + for (CLResource resource : array) { + resource.release(); + } } } @@ -501,7 +503,10 @@ public class CLContext extends CLObject implements CLResource { release(samplers); for (CLDevice device : getDevices()) { - release(queuesMap.get(device)); + Collection queues = queuesMap.get(device); + if(queues != null) { + release(queues); + } } }finally{ -- cgit v1.2.3