Index: trunk/src/org/openstreetmap/josm/io/GpxImporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/GpxImporter.java	(revision 2061)
+++ trunk/src/org/openstreetmap/josm/io/GpxImporter.java	(revision 2062)
@@ -10,4 +10,6 @@
 import java.io.InputStream;
 import java.util.zip.GZIPInputStream;
+
+import javax.swing.SwingUtilities;
 
 import org.openstreetmap.josm.Main;
@@ -23,9 +25,8 @@
     }
 
-    @Override public void importData(File file) throws IOException {
-        String fn = file.getName();
+    @Override public void importData(final File file) throws IOException {
+        final String fn = file.getName();
 
         try {
-            GpxReader r = null;
             InputStream is;
             if (file.getName().endsWith(".gpx.gz")) {
@@ -44,13 +45,25 @@
                 }
             }
-            r = new GpxReader(is, file.getAbsoluteFile().getParentFile());
+            final GpxReader r = new GpxReader(is, file.getAbsoluteFile().getParentFile());
             r.data.storageFile = file;
-            GpxLayer gpxLayer = new GpxLayer(r.data, fn, true);
-            Main.main.addLayer(gpxLayer);
-            if (Main.pref.getBoolean("marker.makeautomarkers", true)) {
-                MarkerLayer ml = new MarkerLayer(r.data, tr("Markers from {0}", fn), file, gpxLayer);
-                if (ml.data.size() > 0) {
-                    Main.main.addLayer(ml);
+            final GpxLayer gpxLayer = new GpxLayer(r.data, fn, true);
+
+            // FIXME: remove UI stuff from the IO subsystem
+            //
+            Runnable task = new Runnable() {
+                public void run() {
+                    Main.main.addLayer(gpxLayer);
+                    if (Main.pref.getBoolean("marker.makeautomarkers", true)) {
+                        MarkerLayer ml = new MarkerLayer(r.data, tr("Markers from {0}", fn), file, gpxLayer);
+                        if (ml.data.size() > 0) {
+                            Main.main.addLayer(ml);
+                        }
+                    }
                 }
+            };
+            if (SwingUtilities.isEventDispatchThread()) {
+                task.run();
+            } else {
+                SwingUtilities.invokeLater(task);
             }
         } catch (FileNotFoundException e) {
