summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/DisplayImpl.java2
-rw-r--r--src/newt/classes/jogamp/newt/PointerIconImpl.java20
2 files changed, 15 insertions, 7 deletions
diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java
index 7fdcb4d7d..8c0240ffd 100644
--- a/src/newt/classes/jogamp/newt/DisplayImpl.java
+++ b/src/newt/classes/jogamp/newt/DisplayImpl.java
@@ -96,7 +96,7 @@ public abstract class DisplayImpl extends Display {
if(DEBUG) {
System.err.println("destroyAllPointerIconFromList: dpy "+toHexString(dpy)+", # "+i+"/"+count+": "+item+" @ "+getThreadName());
}
- if( null != item && item.isValid() ) {
+ if( null != item ) {
item.destroyOnEDT(dpy);
}
}
diff --git a/src/newt/classes/jogamp/newt/PointerIconImpl.java b/src/newt/classes/jogamp/newt/PointerIconImpl.java
index e0a47fed2..57f613fea 100644
--- a/src/newt/classes/jogamp/newt/PointerIconImpl.java
+++ b/src/newt/classes/jogamp/newt/PointerIconImpl.java
@@ -55,6 +55,9 @@ public class PointerIconImpl implements PointerIcon {
this.pixels = pixels;
this.hotspot = hotspot;
this.handle=handle;
+ if( 0 == handle ) {
+ throw new IllegalArgumentException("0 native handle: "+this);
+ }
}
public PointerIconImpl(final DisplayImpl display, final PixelRectangle pixelrect, final PointImmutable hotspot, final long handle) {
this.display = display;
@@ -63,6 +66,9 @@ public class PointerIconImpl implements PointerIcon {
this.pixels = pixelrect.getPixels();
this.hotspot = hotspot;
this.handle=handle;
+ if( 0 == handle ) {
+ throw new IllegalArgumentException("0 native handle: "+this);
+ }
}
@Override
@@ -113,7 +119,7 @@ public class PointerIconImpl implements PointerIcon {
if(Display.DEBUG) {
System.err.println("PointerIcon.destroy: "+this+", "+display+", "+Display.getThreadName());
}
- if( 0 != handle ) {
+ if( 0 != handle ) { // early out
synchronized(display.pointerIconList) {
display.pointerIconList.remove(this);
}
@@ -126,14 +132,16 @@ public class PointerIconImpl implements PointerIcon {
}
}
- /** No checks, assume execution on EDT */
+ /** assume execution on EDT */
synchronized void destroyOnEDT(final long dpy) {
final long h = handle;
handle = 0;
- try {
- display.destroyPointerIconImpl(dpy, h);
- } catch (final Exception e) {
- e.printStackTrace();
+ if( 0 != h ) { // avoid double free
+ try {
+ display.destroyPointerIconImpl(dpy, h);
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
}
}