]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/load/xml/XmlFileLoader.java
Version 11.1, August 2010
[GpsPrune.git] / tim / prune / load / xml / XmlFileLoader.java
index 7fa5ec1b80f8b1d693686dacb1cd2483709b1f89..d528420029a325f8cfc33238de6c80b5c55ef8cc 100644 (file)
@@ -1,6 +1,8 @@
 package tim.prune.load.xml;
 
 import java.io.File;
+import java.io.FileInputStream;
+
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
@@ -61,11 +63,13 @@ public class XmlFileLoader extends DefaultHandler implements Runnable
         */
        public void run()
        {
+               FileInputStream inStream = null;
                try
                {
                        // Construct a SAXParser and use this as a default handler
                        SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
-                       saxParser.parse(_file, this);
+                       inStream = new FileInputStream(_file);
+                       saxParser.parse(inStream, this);
 
                        // Check whether handler was properly instantiated
                        if (_handler == null)
@@ -80,11 +84,16 @@ public class XmlFileLoader extends DefaultHandler implements Runnable
                                SourceInfo sourceInfo = new SourceInfo(_file,
                                        (_handler instanceof GpxHandler?SourceInfo.FILE_TYPE.GPX:SourceInfo.FILE_TYPE.KML));
                                _app.informDataLoaded(_handler.getFieldArray(), _handler.getDataArray(),
-                                       Altitude.Format.METRES, sourceInfo);
+                                       Altitude.Format.METRES, sourceInfo, _handler.getTrackNameList());
                        }
                }
                catch (Exception e)
                {
+                       // clean up file stream
+                       try {
+                               inStream.close();
+                       }
+                       catch (Exception e2) {}
                        // Show error dialog
                        _app.showErrorMessageNoLookup("error.load.dialogtitle",
                                I18nManager.getText("error.load.othererror") + " " + e.getMessage());