javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Image.java
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Image.java Mon Aug 23 14:24:31 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Image.java Thu Sep 02 13:22:59 2010 +0300
@@ -331,14 +331,14 @@
public Image(Device device, String filename) {
this(device, filename, true);
}
-
+
private Image(Device device, String filename, boolean securityCheck) {
this(device);
if (filename == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}
init();
-
+
if (securityCheck == true) {
// Drop the "file:///" prefix
String trimmedFileName = filename.trim();
@@ -391,35 +391,35 @@
SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
}
}
-
+
static Image createImageWithoutSecurityCheck(Device device, String filename) {
return new Image(device, filename, false);
}
-
+
/*
* Returns the bounds of an image without creating an Image instance.
*/
static Point getImageSize(Device device, String filename) {
-
+
if (filename == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}
-
+
InputStream is = device.getClass().getResourceAsStream(filename);
-
+
if (is == null) {
SWT.error(SWT.ERROR_IO);
}
-
+
return getImageSize(is);
}
-
+
/*
* Returns the bounds of an image without creating an Image instance.
*/
static Point getImageSize(InputStream stream) {
Point point = null;
-
+
try {
point = org.eclipse.swt.internal.qt.graphics.ImageLoader.getImageSize(stream);
} catch (IOException e) {
@@ -429,7 +429,7 @@
} catch (IllegalArgumentException e) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
-
+
return point;
}
@@ -564,9 +564,6 @@
int width = image.width;
int height = image.height;
PaletteData palette = image.palette;
- if (!(((image.depth == 1 || image.depth == 2 || image.depth == 4 || image.depth == 8) && !palette.isDirect) ||
- ((image.depth == 8) || (image.depth == 16 || image.depth == 24 || image.depth == 32) && palette.isDirect)))
- SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH);
byte[] buffer = image.data;
if (image.depth != 32 || image.bytesPerLine != width*4) {
buffer = new byte[width * 4 * height];
@@ -697,9 +694,13 @@
if(isDisposed()) {
SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
}
- if(icon == SWT.NULL) {
- icon = OS.QIcon_new(cgImage.getNativePixmapHandle());
+ // Delete any previous icons if there is one
+ // QIcon instances are deleted on Image
+ if( icon != SWT.NULL ){
+ OS.QIcon_delete(icon);
}
+
+ icon = OS.QIcon_new(cgImage.getNativePixmapHandle());
return icon;
}
@@ -828,7 +829,7 @@
}
return Device.nullIconHandle;
}
-
+
/**
* Creates new Image instance.
* <p>