Index: trunk/src/org/openstreetmap/josm/data/osm/Relation.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/Relation.java	(revision 3106)
+++ trunk/src/org/openstreetmap/josm/data/osm/Relation.java	(revision 3107)
@@ -334,11 +334,15 @@
     @Override
     public BBox getBBox() {
-        if (bbox == null) {
-            calculateBBox(new HashSet<PrimitiveId>());
+        if (getDataSet() == null)
+            return calculateBBox(new HashSet<PrimitiveId>());
+        else {
             if (bbox == null) {
-                bbox = new BBox(0, 0, 0, 0); // No members
-            }
-        }
-        return  bbox;
+                bbox = calculateBBox(new HashSet<PrimitiveId>());
+                if (bbox == null) {
+                    bbox = new BBox(0, 0, 0, 0); // No members
+                }
+            }
+            return  bbox;
+        }
     }
 
@@ -374,4 +378,5 @@
         super.setDataset(dataSet);
         checkMembers();
+        bbox = null; // bbox might have changed if relation was in ds, was removed, modified, added back to dataset
     }
 
@@ -401,5 +406,5 @@
     /**
      * Replies true if at least one child primitive is incomplete
-     * 
+     *
      * @return true if at least one child primitive is incomplete
      */
@@ -414,5 +419,5 @@
      * Replies a collection with the incomplete children this relation
      * refers to
-     * 
+     *
      * @return the incomplete children. Empty collection if no children are incomplete.
      */
Index: trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java	(revision 3106)
+++ trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java	(revision 3107)
@@ -65,3 +65,33 @@
     }
 
+    @Test
+    public void testBBoxNotInDataset() {
+        Node n1 = new Node(new LatLon(10, 10));
+        Node n2 = new Node(new LatLon(20, 20));
+        Way w1 = new Way();
+        w1.addNode(n1);
+        w1.addNode(n2);
+        Relation r1 = new Relation();
+        r1.getBBox();
+        r1.addMember(new RelationMember("", w1));
+
+        Assert.assertEquals(new BBox(w1), r1.getBBox());
+
+        DataSet ds = new DataSet();
+        ds.addPrimitive(n1);
+        ds.addPrimitive(n2);
+        ds.addPrimitive(w1);
+        ds.addPrimitive(r1);
+
+        Assert.assertEquals(new BBox(w1), r1.getBBox());
+
+        ds.removePrimitive(r1);
+
+        n1.setCoor(new LatLon(30, 40));
+        Assert.assertEquals(new BBox(w1), r1.getBBox());
+
+        ds.addPrimitive(r1);
+        Assert.assertEquals(new BBox(w1), r1.getBBox());
+    }
+
 }
