From 713c3c3fa953d8561ebc6a52cfee7eadde661bf1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 15 Sep 2015 12:24:56 +0200 Subject: Fix NEWT DisplayImpl.createPointerIcon: Pass through Exceptions, as required by API doc. --- src/newt/classes/jogamp/newt/DisplayImpl.java | 34 +++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index c1cd6db32..61a39c133 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -118,6 +118,8 @@ public abstract class DisplayImpl extends Display { return null; } final PointerIconImpl[] res = { null }; + final Exception[] ex = { null }; + final String exStr = "Could not resolve "+pngResource.resourcePaths[0]; runOnEDTIfAvail(true, new Runnable() { public void run() { try { @@ -126,7 +128,7 @@ public abstract class DisplayImpl extends Display { } final URLConnection urlConn = pngResource.resolve(0); if( null == urlConn ) { - throw new IOException("Could not resolve "+pngResource.resourcePaths[0]); + throw new IOException(exStr); } final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), getNativePointerIconPixelFormat(), @@ -138,20 +140,32 @@ public abstract class DisplayImpl extends Display { if( DEBUG_POINTER_ICON ) { System.err.println("createPointerIconPNG.0: "+image+", handle: "+toHexString(handle)+", hot "+hotspot); } - if( 0 != handle ) { - res[0] = new PointerIconImpl(DisplayImpl.this, image, hotspot, handle); - if( DEBUG_POINTER_ICON ) { - System.err.println("createPointerIconPNG.0: "+res[0]); - } + if( 0 == handle ) { + throw new IOException(exStr); + } + res[0] = new PointerIconImpl(DisplayImpl.this, image, hotspot, handle); + if( DEBUG_POINTER_ICON ) { + System.err.println("createPointerIconPNG.0: "+res[0]); } } catch (final Exception e) { - e.printStackTrace(); + ex[0] = e; } } } ); - if( null != res[0] ) { - synchronized(pointerIconList) { - pointerIconList.add(res[0]); + if( null != ex[0] ) { + final Exception e = ex[0]; + if( e instanceof IllegalArgumentException) { + throw new IllegalArgumentException(e); + } + if( e instanceof IllegalStateException) { + throw new IllegalStateException(e); } + throw new IOException(e); + } + if( null == res[0] ) { + throw new IOException(exStr); + } + synchronized(pointerIconList) { + pointerIconList.add(res[0]); } return res[0]; } -- cgit v1.2.3