Index: /trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java	(revision 4528)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java	(revision 4529)
@@ -15,6 +15,4 @@
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.awt.font.TextAttribute;
-import java.awt.geom.Rectangle2D;
 import java.awt.image.ImageObserver;
 import java.io.File;
@@ -22,5 +20,4 @@
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -69,5 +66,4 @@
 import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
 import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
-import org.openstreetmap.josm.tools.OpenBrowser;
 
 /**
@@ -132,4 +128,5 @@
         }*/
     }
+    
     @Override
     public TileCache getTileCache()
@@ -137,11 +134,11 @@
         return tileCache;
     }
+
     void clearTileCache()
     {
-        /*if (debug) {
-            Main.debug("clearing tile storage");
-        }*/
-        tileCache = new MemoryTileCache();
-        tileCache.setCacheSize(200);
+        tileCache.clear();
+        if (tileLoader instanceof OsmFileCacheTileLoader) {
+            ((OsmFileCacheTileLoader)tileLoader).clearCache(tileSource);
+        }
     }
 
@@ -244,5 +241,6 @@
         currentZoomLevel = getBestZoom();
 
-        clearTileCache();
+        tileCache = new MemoryTileCache();
+
         String cachePath = TMSLayer.PROP_TILECACHE_DIR.get();
         tileLoader = null;
@@ -441,7 +439,5 @@
                     @Override
                     public void actionPerformed(ActionEvent ae) {
-                        //Main.debug("flushing all tiles...");
                         clearTileCache();
-                        //Main.debug("done");
                     }
                 }));
@@ -560,5 +556,5 @@
     }
     public boolean decreaseZoomLevel() {
-        int minZoom = this.getMinZoomLvl();
+        //int minZoom = this.getMinZoomLvl();
         if (zoomDecreaseAllowed()) {
             /*if (debug) {
@@ -784,5 +780,5 @@
         // need to return *all* tiles to the callers, so force creation
         // here.
-        boolean forceTileCreation = true;
+        //boolean forceTileCreation = true;
         for (Tile tile : ts.allTilesCreate()) {
             Image img = getLoadedTileImage(tile);
@@ -842,6 +838,6 @@
         }
 
-        String tileStatus = tile.getStatus();
-        /*if (!tile.isLoaded() && PROP_DRAW_DEBUG.get()) {
+        /*String tileStatus = tile.getStatus();
+        if (!tile.isLoaded() && PROP_DRAW_DEBUG.get()) {
             myDrawString(g, tr("image " + tileStatus), p.x + 2, texty);
             texty += 1 + fontHeight;
