Revision: 3059 http://vexi.svn.sourceforge.net/vexi/?rev=3059&view=rev Author: mkpg2 Date: 2008-08-09 22:43:41 +0000 (Sat, 09 Aug 2008)
Log Message: ----------- Fix. Make handling of IOException more uniform. Change textures to trigger fill write with JSExn, not null if they do not load. Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src/org/vexi/core/Resources.java trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2008-08-09 22:37:28 UTC (rev 3058) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2008-08-09 22:43:41 UTC (rev 3059) @@ -269,9 +269,9 @@ // Tiled images affect contentsize if (test(TILE_IMAGE)) setConstrain(); dirty(); - } else if (texture.loadFailed) { + } else if (texture.loadFailed!=null) { //JS res = texture.stream; - justTriggerTraps(SC_fill, null); + justTriggerTraps(SC_fill, texture.loadFailed.getObject()); texture = null; //throw new JSExn("Image not found: "+res.unclone()); } else { Modified: trunk/core/org.vexi.core/src/org/vexi/core/Resources.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2008-08-09 22:37:28 UTC (rev 3058) +++ trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2008-08-09 22:43:41 UTC (rev 3059) @@ -23,7 +23,6 @@ import org.ibex.js.JS.Enumeration; import org.ibex.js.JS.Keys; import org.ibex.js.JSU.Wrapper; -import org.ibex.net.HTTP.HTTPException; import org.ibex.util.Basket; import org.ibex.util.Callable; import org.ibex.util.Encode; @@ -446,10 +445,6 @@ is.close(); } - static private JSExn handle(IOException e){ - if(e instanceof HTTPException) return new JSExn(JSU.S(e.getMessage()),SC_http); - return new JSExn(e.getMessage()); - } static final int[] ARGTYPES_parseUTF8 = new int[]{JSU.FOUNTAIN}; static public JS parseUTF8(JS[] args) throws JSExn { @@ -463,7 +458,7 @@ is.close(); } }catch(IOException e){ - throw handle(e); + throw JSU.handleFountainExn(e); } } @@ -478,7 +473,7 @@ out.close(); } }catch(IOException e){ - throw handle(e); + throw JSU.handleFountainExn(e); } } @@ -543,14 +538,14 @@ return null; } }catch(IOException e){ - throw handle(e); + throw JSU.handleFountainExn(e); } return super.call(method, args); } }; return writer; }catch(IOException e){ - throw handle(e); + throw JSU.handleFountainExn(e); } } @@ -634,7 +629,7 @@ } catch (XML.Exn e) { throw new JSExn("error parsing XML: " + e.toString()); } catch (IOException e) { - throw handle(e); + throw JSU.handleFountainExn(e); } } } Modified: trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2008-08-09 22:37:28 UTC (rev 3058) +++ trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2008-08-09 22:43:41 UTC (rev 3059) @@ -121,10 +121,10 @@ // FEATURE create JSExn constructor that takes a SourceException - // and so pass on more information as exception properties. throw new JSExn("Could not parse xml, " + sourceName()); - }catch(Exception e){ - Log.error(TemplateHelper.class, e); - throw new JSExn("Unexpected error when parsing, " + sourceName()); } + catch(IOException e){ + throw JSU.handleFountainExn(e); + } } final private String sourceName(){ return unresolved.staticPart.sourceName; } Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java 2008-08-09 22:37:28 UTC (rev 3058) +++ trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java 2008-08-09 22:43:41 UTC (rev 3059) @@ -4,13 +4,11 @@ package org.vexi.graphics; -import java.io.InputStream; -import java.io.PushbackInputStream; +import java.io.*; import java.util.WeakHashMap; import org.ibex.js.*; import org.ibex.util.Callable; -import org.ibex.util.Log; import org.ibex.util.Vec; import org.vexi.core.Blessing; import org.vexi.plat.Platform; @@ -36,7 +34,7 @@ public int[] data = null; ///< argb samples public boolean isLoaded = false; ///< true iff the image is fully loaded // FIXME: this is a hack to disguise isLoaded somehow being false when callbacks are run - public boolean loadFailed = false; ///< true iff the image loading failed + public JSExn loadFailed = null; ///< not null iff the image loading failed private Vec loadedCallbacks; @@ -86,38 +84,37 @@ loadedCallbacks.addElement(callback); new java.lang.Thread() { public void run() { - try { - InputStream in = b == null ? - Fountain.getInputStream(stream) : b.getImage(); - if (in == null) throw new JSExn("not a valid image stream"); - - PushbackInputStream pbis = new PushbackInputStream(in); - int firstByte = pbis.read(); - if (firstByte == -1) throw new JSExn("empty stream reading image"); - pbis.unread(firstByte); - if ((firstByte & 0xff) == 'G') GIF.load(pbis, Picture.this); - else if ((firstByte & 0xff) == 137) PNG.load(pbis, Picture.this); - else if ((firstByte & 0xff) == 0xff) Platform.decodeJPEG(pbis, Picture.this); - else throw new JSExn("couldn't figure out image type from first byte"); - isLoaded = true; - } catch (Exception e) { - loadFailed = true; - Log.warn(Picture.class,"Couldn't load picture from stream " + stream.unclone()); - if(e instanceof JSExn) Log.uWarn(Picture.class,e.getMessage()); - else { - Log.uWarn(Picture.class,"System error loading image"); - Log.warn(Picture.class, e); - } - } finally { + try { + try { + InputStream in = b == null ? + Fountain.getInputStream(stream) : b.getImage(); + if (in == null) throw new JSExn("not a valid image stream"); + + PushbackInputStream pbis = new PushbackInputStream(in); + int firstByte = pbis.read(); + if (firstByte == -1) throw new JSExn("empty stream reading image"); + pbis.unread(firstByte); + if ((firstByte & 0xff) == 'G') GIF.load(pbis, Picture.this); + else if ((firstByte & 0xff) == 137) PNG.load(pbis, Picture.this); + else if ((firstByte & 0xff) == 0xff) Platform.decodeJPEG(pbis, Picture.this); + else throw new JSExn("couldn't figure out image type from first byte"); + isLoaded = true; + } catch (IOException e) { + throw JSU.handleFountainExn(e); + } + } catch(JSExn e){ + loadFailed = e; + } + finally { loaded(); } } }.start(); } } - + /* public String toString(){ return "Picture "+stream+", " +(isLoaded?"loaded":(loadFailed?"failed":"not loaded"))+", " +(loadedCallbacks==null?"no":""+loadedCallbacks.size())+" callbacks"; - } + }*/ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn