scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java | 49 ++++------ 1 file changed, 23 insertions(+), 26 deletions(-)
New commits: commit b50fedfc348eb9a834b6626dc95e3538c4962a47 Author: rbuj <robert....@gmail.com> Date: Sat Sep 6 21:15:33 2014 +0200 scripting: avoid a possible NullPointerException Change-Id: I90589bc042f4b88b700e9f3c167c460c3cff043c Reviewed-on: https://gerrit.libreoffice.org/11311 Reviewed-by: Noel Grandin <noelgran...@gmail.com> Tested-by: Noel Grandin <noelgran...@gmail.com> diff --git a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java index 5c744b1..6073eb0 100644 --- a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java +++ b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java @@ -64,46 +64,43 @@ public class ScriptBrowseNode extends PropertySet this.provider = provider; this.name = name; this.parent = parent; - ScriptMetaData data = null; - XSimpleFileAccess xSFA = null; XComponentContext xCtx = provider.getScriptingContext().getComponentContext(); XMultiComponentFactory xFac = xCtx.getServiceManager(); try { - data = (ScriptMetaData)parent.getByName( name ); - xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class, + ScriptMetaData data = (ScriptMetaData)parent.getByName( name ); + XSimpleFileAccess xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class, xFac.createInstanceWithContext( "com.sun.star.ucb.SimpleFileAccess", xCtx ) ); - } - - // TODO fix exception types to be caught here, should we rethrow? - catch ( Exception e ) - { - LogUtils.DEBUG("** caught exception getting script data for " + name + " ->" + e.toString() ); - } - - if (provider.hasScriptEditor()) - { - this.editable = true; - try + if (provider.hasScriptEditor()) { - if ( !parent.isUnoPkg() && - !xSFA.isReadOnly( parent.getPathToParcel() ) ) + this.editable = true; + try { - this.deletable = true; - this.renamable = true; + if (!parent.isUnoPkg() + && !xSFA.isReadOnly(parent.getPathToParcel())) + { + this.deletable = true; + this.renamable = true; + } } - } - // TODO propagate errors - catch ( Exception e ) - { - LogUtils.DEBUG("Caught exception in creation of ScriptBrowseNode"); - LogUtils.DEBUG( LogUtils.getTrace(e)); + // TODO propagate errors + catch (Exception e) + { + LogUtils.DEBUG("Caught exception in creation of ScriptBrowseNode"); + LogUtils.DEBUG(LogUtils.getTrace(e)); + } + } } + // TODO fix exception types to be caught here, should we rethrow? + catch ( Exception e ) + { + LogUtils.DEBUG("** caught exception getting script data for " + name + " ->" + e.toString() ); + } registerProperty("Deletable", new Type(boolean.class), (short)0, "deletable"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits