Index: trunk/src/org/openstreetmap/josm/command/SelectCommand.java
===================================================================
--- trunk/src/org/openstreetmap/josm/command/SelectCommand.java	(revision 12349)
+++ trunk/src/org/openstreetmap/josm/command/SelectCommand.java	(revision 12350)
@@ -59,4 +59,6 @@
     @Override
     public void undoCommand() {
+        ensurePrimitivesAreInDataset();
+
         getAffectedDataSet().setSelected(oldSelection);
     }
@@ -64,7 +66,14 @@
     @Override
     public boolean executeCommand() {
+        ensurePrimitivesAreInDataset();
+
         oldSelection = getAffectedDataSet().getSelected();
         getAffectedDataSet().setSelected(newSelection);
         return true;
+    }
+
+    @Override
+    public Collection<? extends OsmPrimitive> getParticipatingPrimitives() {
+        return Collections.unmodifiableCollection(newSelection);
     }
 
