You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Greg Brown <gk...@mac.com> on 2010/09/07 00:02:14 UTC

Re: svn commit: r993158 - in /pivot/trunk/wtk/src/org/apache/pivot/wtk: ApplicationContext.java ScriptApplication.java

>         private Component focusedComponent = null;
> @@ -1520,6 +1520,8 @@ public abstract class ApplicationContext
>             throw new RuntimeException(exception);
>         } catch (SerializationException exception) {
>             throw new RuntimeException(exception);
> +        } catch (NullPointerException exception) {
> +            throw new RuntimeException("Unable to locate style sheet resource \"" + resourceName + "\".");
>         }

No. This is just silly. You don't catch NPEs - you prevent them. The appropriate way to handle this is to check for a null return value from ClassLoader#getResource().

> Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ScriptApplication.java
> URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ScriptApplication.java?rev=993158&r1=993157&r2=993158&view=diff
> ==============================================================================
> --- pivot/trunk/wtk/src/org/apache/pivot/wtk/ScriptApplication.java (original)
> +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ScriptApplication.java Mon Sep  6 21:45:25 2010
> @@ -66,7 +66,10 @@ public class ScriptApplication implement
> 
>         if (properties.containsKey(STYLESHEET_KEY)) {
>             String stylesheet = properties.get(STYLESHEET_KEY);
> -            ApplicationContext.applyStylesheet(stylesheet.substring(1));
> +            if (stylesheet.startsWith("/")) {
> +                stylesheet = stylesheet.substring(1);
> +            }
> +            ApplicationContext.applyStylesheet(stylesheet);
>         }

The leading slash is required. We can display an error when it is missing, but it should not be optional.