summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/java/awt/image/PixelGrabber.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/awt/image/PixelGrabber.java')
-rw-r--r--libjava/classpath/java/awt/image/PixelGrabber.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/libjava/classpath/java/awt/image/PixelGrabber.java b/libjava/classpath/java/awt/image/PixelGrabber.java
index b576dbfad98..b8ca70c3379 100644
--- a/libjava/classpath/java/awt/image/PixelGrabber.java
+++ b/libjava/classpath/java/awt/image/PixelGrabber.java
@@ -131,6 +131,9 @@ public class PixelGrabber implements ImageConsumer
public PixelGrabber(ImageProducer ip, int x, int y, int w, int h,
int pix[], int off, int scansize)
{
+ if (ip == null)
+ throw new NullPointerException("The ImageProducer must not be null.");
+
this.ip = ip;
this.x = x;
this.y = y;
@@ -179,6 +182,10 @@ public class PixelGrabber implements ImageConsumer
boolean forceRGB)
{
this.ip = img.getSource();
+
+ if (this.ip == null)
+ throw new NullPointerException("The ImageProducer must not be null.");
+
this.x = x;
this.y = y;
width = w;
@@ -209,7 +216,15 @@ public class PixelGrabber implements ImageConsumer
{
public void run ()
{
- ip.startProduction (PixelGrabber.this);
+ try
+ {
+ ip.startProduction (PixelGrabber.this);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ imageComplete(ImageConsumer.IMAGEABORTED);
+ }
}
};
grabberThread.start ();
@@ -601,7 +616,8 @@ public class PixelGrabber implements ImageConsumer
consumerStatus = status;
setObserverStatus ();
grabbing = false;
- ip.removeConsumer (this);
+ if (ip != null)
+ ip.removeConsumer (this);
notifyAll ();
}
OpenPOWER on IntegriCloud