abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/juloo.keyboard2')
-rw-r--r--srcs/juloo.keyboard2/KeyboardData.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java
index f1f43d7..3432fe1 100644
--- a/srcs/juloo.keyboard2/KeyboardData.java
+++ b/srcs/juloo.keyboard2/KeyboardData.java
@@ -193,21 +193,22 @@ public final class KeyboardData
/** Load a layout from a resource ID. Returns [null] on error. */
public static KeyboardData load(Resources res, int id)
{
- KeyboardData l = _layoutCache.get(id);
- if (l == null)
+ if (_layoutCache.containsKey(id))
+ return _layoutCache.get(id);
+ KeyboardData l = null;
+ XmlResourceParser parser = null;
+ try
{
- try
- {
- XmlResourceParser parser = res.getXml(id);
- l = parse_keyboard(parser);
- parser.close();
- _layoutCache.put(id, l);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
+ parser = res.getXml(id);
+ l = parse_keyboard(parser);
+ }
+ catch (Exception e)
+ {
+ Logs.exn("Failed to load layout id " + id, e);
}
+ if (parser != null)
+ parser.close();
+ _layoutCache.put(id, l);
return l;
}