[Schmitzm-commits] r1946 - trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Sat Apr 14 20:52:27 CEST 2012


Author: alfonx
Date: 2012-04-14 20:52:27 +0200 (Sat, 14 Apr 2012)
New Revision: 1946

Modified:
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapFrame.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapPane.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPane.java
Log:
React to the following log warnings by disposing mapContext in XMapPane.dispose()

Apr 14, 2012 7:43:47 PM org.geotools.map.MapContent finalize
SEVERE: Call MapContent dispose() to prevent memory leaks

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapFrame.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapFrame.java	2012-04-14 17:34:25 UTC (rev 1945)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapFrame.java	2012-04-14 18:52:27 UTC (rev 1946)
@@ -256,7 +256,7 @@
 		Vector<MapLayer> rasterLayer = new Vector<MapLayer>();
 		Vector<String> rasterLayerDesc = new Vector<String>();
 		for (MapLayer layer : mapPane.getMapContext().getLayers())
-			if (mapPane.isGridCoverageLayer(layer)) {
+			if (SelectableXMapPane.isGridCoverageLayer(layer)) {
 				rasterLayer.add(layer);
 				rasterLayerDesc.add(layer.getTitle());
 			}

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapPane.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapPane.java	2012-04-14 17:34:25 UTC (rev 1945)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapPane.java	2012-04-14 18:52:27 UTC (rev 1946)
@@ -206,7 +206,7 @@
 	 * <li>{@link FeatureCollection org.geotools.feature.FeatureCollection}</li>
 	 * </ul>
 	 */
-	public boolean isVisualisable(Class c) {
+	public boolean isVisualisable(Class<?> c) {
 		return GridCoverage2D.class.isAssignableFrom(c)
 				|| FeatureCollection.class.isAssignableFrom(c);
 	}

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPane.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPane.java	2012-04-14 17:34:25 UTC (rev 1945)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPane.java	2012-04-14 18:52:27 UTC (rev 1946)
@@ -1050,8 +1050,6 @@
 	 * the GarbageCollector
 	 * 
 	 * Removes all {@link JMapPaneListener}s that are registered
-	 * 
-	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public void dispose() {
 		if (isDisposed())
@@ -1097,10 +1095,15 @@
 		removeMouseMotionListener(xMapPaneMouseListener);
 		removeMouseListener(xMapPaneMouseListener);
 
+		/*
+		 * Dispose both MapContexts. If not, you will be warned by GT:
+		 * <code>org.geotools.map.MapContent finalize<br/>SEVERE: Call
+		 * MapContent dispose() to prevent memory leaks</code>
+		 */
 		if (localContext != null)
-			getMapContext().clearLayerList();
+			getMapContext().dispose();
 		if (bgContext != null)
-			getBgContext().clearLayerList();
+			getBgContext().dispose();
 
 		removeAll();
 	}



More information about the Schmitzm-commits mailing list