diff options
author | rbuj <robert.buj@gmail.com> | 2014-09-06 21:15:33 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2014-09-11 06:13:40 +0000 |
commit | b50fedfc348eb9a834b6626dc95e3538c4962a47 (patch) | |
tree | ddf39b01b0efc776eb1cc510e3d66274ea2c7e7d | |
parent | d44ace5d50b41a7a68d77f16a77b31786e3a7f12 (diff) |
scripting: avoid a possible NullPointerException
Change-Id: I90589bc042f4b88b700e9f3c167c460c3cff043c
Reviewed-on: https://gerrit.libreoffice.org/11311
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r-- | scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java | 49 |
1 files changed, 23 insertions, 26 deletions
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 5c744b1bdcd6..6073eb03b243 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"); |