changeset 148:837a633a0407

fixed bugs when using lots of prescaled images
author robcast
date Fri, 22 Aug 2003 21:12:24 +0200
parents bdd6789d21e0
children 04ad64b2137a
files servlet/src/digilib/image/ImageLoaderDocuImage.java servlet/src/digilib/image/ImageLoaderDocuInfo.java servlet/src/digilib/image/JAIImageLoaderDocuImage.java servlet/src/digilib/servlet/Scaler.java
diffstat 4 files changed, 35 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/servlet/src/digilib/image/ImageLoaderDocuImage.java	Fri Aug 22 15:02:21 2003 +0200
+++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java	Fri Aug 22 21:12:24 2003 +0200
@@ -117,6 +117,11 @@
 	 * 
 	 */
 	public void preloadImage(File f) throws IOException {
+		if (reader != null) {
+			// clean up old reader
+			reader.dispose();
+			reader = null;
+		}
 		System.gc();
 		RandomAccessFile rf = new RandomAccessFile(f, "r");
 		ImageInputStream istream = ImageIO.createImageInputStream(rf);
@@ -424,4 +429,16 @@
 		img = mirImg;
 	}
 
+	/* (non-Javadoc)
+	 * @see java.lang.Object#finalize()
+	 */
+	protected void finalize() throws Throwable {
+		//System.out.println("FIN de ImageLoaderDocuImage!");
+		// we must dispose the ImageReader because it keeps the filehandle open!
+		reader.dispose();
+		reader = null;
+		img = null;
+		super.finalize();
+	}
+
 }
--- a/servlet/src/digilib/image/ImageLoaderDocuInfo.java	Fri Aug 22 15:02:21 2003 +0200
+++ b/servlet/src/digilib/image/ImageLoaderDocuInfo.java	Fri Aug 22 21:12:24 2003 +0200
@@ -48,6 +48,9 @@
 		t = FileOps.mimeForFile(f.getFile());
 		f.setMimetype(t);
 		f.setChecked(true);
+		// clean up
+		img.reader.reset();
+		//img.reader = null;
 		return true;
 	}
 
--- a/servlet/src/digilib/image/JAIImageLoaderDocuImage.java	Fri Aug 22 15:02:21 2003 +0200
+++ b/servlet/src/digilib/image/JAIImageLoaderDocuImage.java	Fri Aug 22 21:12:24 2003 +0200
@@ -179,4 +179,16 @@
 		return true;
 	}
 
+	/* (non-Javadoc)
+	 * @see java.lang.Object#finalize()
+	 */
+	protected void finalize() throws Throwable {
+		//System.out.println("FIN de JAIImageLoaderDocuImage!");
+		// we must dispose the ImageReader because it keeps the filehandle open!
+		reader.dispose();
+		reader = null;
+		img = null;
+		super.finalize();
+	}
+
 }
--- a/servlet/src/digilib/servlet/Scaler.java	Fri Aug 22 15:02:21 2003 +0200
+++ b/servlet/src/digilib/servlet/Scaler.java	Fri Aug 22 21:12:24 2003 +0200
@@ -58,7 +58,7 @@
 public class Scaler extends HttpServlet {
 
 	// digilib servlet version (for all components)
-	public static final String dlVersion = "1.12b7";
+	public static final String dlVersion = "1.13a2";
 
 	// Utils instance with debuglevel
 	Utils util;
@@ -447,10 +447,10 @@
 				&& (fileToLoad.getSize().height <= expectedSourceSize.height))
 				|| (autoRes
 					&& ((fileToLoad.getSize().width == expectedSourceSize.width)
-					|| (fileToLoad.getSize().height <= expectedSourceSize.height)))
+					&& (fileToLoad.getSize().height <= expectedSourceSize.height)))
 				|| (autoRes
 					&& ((fileToLoad.getSize().width <= expectedSourceSize.width)
-					|| (fileToLoad.getSize().height == expectedSourceSize.height)))
+					&& (fileToLoad.getSize().height == expectedSourceSize.height)))
 				|| (!autoRes && !scaleToFit && !cropToFit && !absoluteScale)) {
 
 				util.dprintln(1, "Sending File as is.");