diff --git a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java index 4b78ac75..cc99ec37 100644 --- a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java +++ b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java @@ -91,42 +91,46 @@ public class BundledComponentRepository // first we obtain the resource set from whence will come our bundles ResourceBundle[] rbundles = rmgr.getResourceSet(name); + if (rbundles == null) { + // Couldn't find a bundle with that name, so just make empty maps for safe enumerating + fillInWithEmptyMaps(); + return; + } // look for our metadata info in each of the bundles try { - int rcount = (rbundles == null) ? 0 : rbundles.length; - for (int i = 0; i < rcount; i++) { + for (ResourceBundle rbundle : rbundles) { if (_actions == null) { @SuppressWarnings("unchecked") Map amap = (Map)BundleUtil.loadObject( - rbundles[i], BundleUtil.ACTIONS_PATH, true); + rbundle, BundleUtil.ACTIONS_PATH, true); _actions = amap; } if (_actionSets == null) { - @SuppressWarnings("unchecked") Map asets = + @SuppressWarnings("unchecked") Map asets = (Map)BundleUtil.loadObject( - rbundles[i], BundleUtil.ACTION_SETS_PATH, true); + rbundle, BundleUtil.ACTION_SETS_PATH, true); _actionSets = asets; } if (_classes == null) { @SuppressWarnings("unchecked") Map cmap = (Map)BundleUtil.loadObject( - rbundles[i], BundleUtil.CLASSES_PATH, true); + rbundle, BundleUtil.CLASSES_PATH, true); _classes = cmap; } } // now go back and load up all of the component information - for (int i = 0; i < rcount; i++) { - @SuppressWarnings("unchecked") IntMap> comps = + for (ResourceBundle rbundle : rbundles) { + @SuppressWarnings("unchecked") IntMap> comps = (IntMap>)BundleUtil.loadObject( - rbundles[i], BundleUtil.COMPONENTS_PATH, true); + rbundle, BundleUtil.COMPONENTS_PATH, true); if (comps == null) { continue; } // create a frame provider for this bundle - FrameProvider fprov = new ResourceBundleProvider(_imgr, rbundles[i]); + FrameProvider fprov = new ResourceBundleProvider(_imgr, rbundle); // now create char. component instances for each component in the serialized table Iterator iter = comps.keySet().iterator(); @@ -144,6 +148,11 @@ public class BundledComponentRepository // if we failed to load our classes or actions, create empty hashtables so that we can // safely enumerate our emptiness + fillInWithEmptyMaps(); + } + + protected void fillInWithEmptyMaps(){ + if (_actions == null) { _actions = Maps.newHashMap(); } @@ -364,8 +373,8 @@ public class BundledComponentRepository } return actionPath; } - - protected String makePath(CharacterComponent component, String action, String type) + + protected String makePath(CharacterComponent component, String action, String type) { String imgpath = action; if (type != null) { diff --git a/src/java/com/threerings/media/image/BackedVolatileMirage.java b/src/java/com/threerings/media/image/BackedVolatileMirage.java index 3c4ffeaa..85438749 100644 --- a/src/java/com/threerings/media/image/BackedVolatileMirage.java +++ b/src/java/com/threerings/media/image/BackedVolatileMirage.java @@ -57,9 +57,8 @@ public class BackedVolatileMirage extends VolatileMirage @Override protected void refreshVolatileImage () { - Graphics gfx = null; + Graphics gfx = _image.getGraphics(); try { - gfx = _image.getGraphics(); gfx.drawImage(_source, -_bounds.x, -_bounds.y, null); } catch (Exception e) { diff --git a/tests/src/java/com/threerings/util/DirectionTest.java b/tests/src/java/com/threerings/util/DirectionTest.java index fefe56c1..72a808ff 100644 --- a/tests/src/java/com/threerings/util/DirectionTest.java +++ b/tests/src/java/com/threerings/util/DirectionTest.java @@ -25,7 +25,7 @@ import junit.framework.Test; import junit.framework.TestCase; /** - * Tests the {@link Direction} class. + * Tests the {@link DirectionUtil} class. */ public class DirectionTest extends TestCase implements DirectionCodes