Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
index 01f00d8053..2dc3f904a3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.graphics;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -61,6 +61,7 @@ public Image(Device device, Image srcImage, int flag) {
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
this.device = device;
if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
switch (flag) {
case SWT.IMAGE_COPY:
case SWT.IMAGE_DISABLE:
@@ -238,6 +239,7 @@ public boolean equals (Object object) {
}
public Color getBackground() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (transparentPixel == -1) return null;
PhImage_t phImage = new PhImage_t();
@@ -274,13 +276,14 @@ public Color getBackground() {
}
public Rectangle getBounds() {
- if (handle == 0) return new Rectangle(0, 0, 0, 0);
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
PhImage_t image = new PhImage_t();
OS.memmove(image, handle, PhImage_t.sizeof);
return new Rectangle(0, 0, image.size_w, image.size_h);
}
public ImageData getImageData() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
PhImage_t phImage = new PhImage_t();
OS.memmove(phImage, handle, PhImage_t.sizeof);
int depth = 0;
@@ -580,8 +583,11 @@ public boolean isDisposed() {
}
public void setBackground(Color color) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (transparentPixel == -1) return;
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (transparentPixel == -1) return;
+
PhImage_t phImage = new PhImage_t();
OS.memmove(phImage, handle, PhImage_t.sizeof);
int phPalette = phImage.palette;
@@ -609,4 +615,9 @@ public static Image photon_new(Device device, int type, int handle) {
return image;
}
-} \ No newline at end of file
+public String toString () {
+ if (isDisposed()) return "Image {*DISPOSED*}";
+ return "Image {" + handle + "}";
+}
+
+}

Back to the top