Index: trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java	(revision 4709)
+++ trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java	(revision 4710)
@@ -70,5 +70,8 @@
 
     public MarkerLayer(GpxData indata, String name, File associatedFile, GpxLayer fromLayer) {
-
+        this(indata, name, associatedFile, fromLayer, true);
+    }
+
+    public MarkerLayer(GpxData indata, String name, File associatedFile, GpxLayer fromLayer, boolean addMouseHandlerInConstructor) {
         super(name);
         this.setAssociatedFile(associatedFile);
@@ -88,42 +91,48 @@
         }
 
-        SwingUtilities.invokeLater(new Runnable(){
-            public void run() {
-                Main.map.mapView.addMouseListener(new MouseAdapter() {
-                    @Override public void mousePressed(MouseEvent e) {
-                        if (e.getButton() != MouseEvent.BUTTON1)
-                            return;
-                        boolean mousePressedInButton = false;
-                        if (e.getPoint() != null) {
-                            for (Marker mkr : data) {
-                                if (mkr.containsPoint(e.getPoint())) {
-                                    mousePressedInButton = true;
-                                    break;
-                                }
-                            }
-                        }
-                        if (! mousePressedInButton)
-                            return;
-                        mousePressed  = true;
-                        if (isVisible()) {
-                            Main.map.mapView.repaint();
+        if (addMouseHandlerInConstructor) {
+            SwingUtilities.invokeLater(new Runnable(){
+                public void run() {
+                    addMouseHandler();
+                }
+            });
+        }
+    }
+
+    public void addMouseHandler() {
+        Main.map.mapView.addMouseListener(new MouseAdapter() {
+            @Override public void mousePressed(MouseEvent e) {
+                if (e.getButton() != MouseEvent.BUTTON1)
+                    return;
+                boolean mousePressedInButton = false;
+                if (e.getPoint() != null) {
+                    for (Marker mkr : data) {
+                        if (mkr.containsPoint(e.getPoint())) {
+                            mousePressedInButton = true;
+                            break;
                         }
                     }
-                    @Override public void mouseReleased(MouseEvent ev) {
-                        if (ev.getButton() != MouseEvent.BUTTON1 || ! mousePressed)
-                            return;
-                        mousePressed = false;
-                        if (!isVisible())
-                            return;
-                        if (ev.getPoint() != null) {
-                            for (Marker mkr : data) {
-                                if (mkr.containsPoint(ev.getPoint())) {
-                                    mkr.actionPerformed(new ActionEvent(this, 0, null));
-                                }
-                            }
+                }
+                if (! mousePressedInButton)
+                    return;
+                mousePressed  = true;
+                if (isVisible()) {
+                    Main.map.mapView.repaint();
+                }
+            }
+            @Override public void mouseReleased(MouseEvent ev) {
+                if (ev.getButton() != MouseEvent.BUTTON1 || ! mousePressed)
+                    return;
+                mousePressed = false;
+                if (!isVisible())
+                    return;
+                if (ev.getPoint() != null) {
+                    for (Marker mkr : data) {
+                        if (mkr.containsPoint(ev.getPoint())) {
+                            mkr.actionPerformed(new ActionEvent(this, 0, null));
                         }
-                        Main.map.mapView.repaint();
                     }
-                });
+                }
+                Main.map.mapView.repaint();
             }
         });
Index: trunk/src/org/openstreetmap/josm/io/GpxImporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/GpxImporter.java	(revision 4709)
+++ trunk/src/org/openstreetmap/josm/io/GpxImporter.java	(revision 4710)
@@ -66,5 +66,5 @@
             }
             if (Main.pref.getBoolean("marker.makeautomarkers", true) && !r.data.waypoints.isEmpty()) {
-                markerLayer = new MarkerLayer(r.data, markerLayerName, associatedFile, gpxLayer);
+                markerLayer = new MarkerLayer(r.data, markerLayerName, associatedFile, gpxLayer, false);
                 if (markerLayer.data.size() == 0) {
                     markerLayer = null;
@@ -74,4 +74,7 @@
                 @Override
                 public void run() {
+                    if (markerLayer != null) {
+                        markerLayer.addMouseHandler();
+                    }
                     if (!parsedProperly) {
                         String msg;
