From d496a97ac863d4b67d72a47e0e86b8496ca9f4dd Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 13 Jul 2012 12:39:21 +0000 Subject: [PATCH] * removed icon cache, just crashes the app sometimes and it's not really necessary anyway * improved startup error handling --- source/ehcache.xml | 15 +----- .../filebot/ApplicationStarter.java | 21 ++++---- .../sourceforge/filebot/ResourceManager.java | 48 ++----------------- .../filebot/ui/rename/FormatDialog.java | 2 +- 4 files changed, 19 insertions(+), 67 deletions(-) diff --git a/source/ehcache.xml b/source/ehcache.xml index f4342798..161c4275 100644 --- a/source/ehcache.xml +++ b/source/ehcache.xml @@ -73,18 +73,5 @@ diskPersistent="false" memoryStoreEvictionPolicy="LRU" /> - - - - + diff --git a/source/net/sourceforge/filebot/ApplicationStarter.java b/source/net/sourceforge/filebot/ApplicationStarter.java index 2cdc466e..ded28fe0 100644 --- a/source/net/sourceforge/filebot/ApplicationStarter.java +++ b/source/net/sourceforge/filebot/ApplicationStarter.java @@ -125,16 +125,21 @@ public class ApplicationStarter { startUserInterface(args); } }); - - // pre-load certain classes and resources in the background - warmupCachedResources(); - - // check for application updates (only when installed, i.e. not running via fatjar or webstart) - if (!"skip".equals(System.getProperty("application.update"))) { - checkUpdate(); - } } catch (Exception e) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, e.getMessage(), e); + System.exit(-1); // starting up UI failed + } + + // pre-load certain classes and resources in the background + warmupCachedResources(); + + // check for application updates (only when installed, i.e. not running via fatjar or webstart) + if (!"skip".equals(System.getProperty("application.update"))) { + try { + checkUpdate(); + } catch (Exception e) { + Logger.getLogger(Main.class.getName()).log(Level.WARNING, "Failed to check for updates", e); + } } } catch (CmdLineException e) { // illegal arguments => just print CLI error message and stop diff --git a/source/net/sourceforge/filebot/ResourceManager.java b/source/net/sourceforge/filebot/ResourceManager.java index 4d66de5a..2fe9bb3d 100644 --- a/source/net/sourceforge/filebot/ResourceManager.java +++ b/source/net/sourceforge/filebot/ResourceManager.java @@ -5,40 +5,26 @@ package net.sourceforge.filebot; import java.awt.Image; import java.io.IOException; import java.net.URL; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.Icon; import javax.swing.ImageIcon; -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Element; - public final class ResourceManager { - private static final Cache cache = CacheManager.getInstance().getCache("resource"); - - public static Icon getIcon(String name) { return getIcon(name, null); } public static Icon getIcon(String name, String def) { - Icon icon = probeCache(name, Icon.class); + URL resource = getImageResource(name, def); - if (icon == null) { - URL resource = getImageResource(name, def); - - if (resource != null) { - icon = populateCache(name, Icon.class, new ImageIcon(resource)); - } - } + if (resource == null) + return null; - return icon; + return new ImageIcon(resource); } @@ -78,32 +64,6 @@ public final class ResourceManager { } - private static T probeCache(String name, Class type) { - try { - Element entry = cache.get(type.getName() + ":" + name); - - if (entry != null) { - return type.cast(entry.getObjectValue()); - } - } catch (Exception e) { - Logger.getLogger(ResourceManager.class.getName()).log(Level.WARNING, e.getMessage()); - } - - return null; - } - - - private static T populateCache(String name, Class type, T value) { - try { - cache.put(new Element(type.getName() + ":" + name, value)); - } catch (Exception e) { - Logger.getLogger(ResourceManager.class.getName()).log(Level.WARNING, e.getMessage()); - } - - return value; - } - - /** * Dummy constructor to prevent instantiation. */ diff --git a/source/net/sourceforge/filebot/ui/rename/FormatDialog.java b/source/net/sourceforge/filebot/ui/rename/FormatDialog.java index 8311ca8e..86ddaaaf 100644 --- a/source/net/sourceforge/filebot/ui/rename/FormatDialog.java +++ b/source/net/sourceforge/filebot/ui/rename/FormatDialog.java @@ -207,7 +207,7 @@ class FormatDialog extends JDialog { // initialize window properties setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - setSize(540, 380); + setSize(540, 395); }