ByteProcessor class pixel[] fieldl become NULL when closing associated ImagePlus windows

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ByteProcessor class pixel[] fieldl become NULL when closing associated ImagePlus windows

Eddie Iannuccelli
Hi,
My plugin write some annotations into a ByteProcessor displayed in an
ImagePlus (I use putPixel,drawString methods, etc.).
My annotated ByteProcessor instance is stored as a field in a dedicated
class so I can display it again and again in a new ImagePlus window if user
unfortunatly close current image (I don't know how to prevent user closing
ImagePlus windows ;).

The null pointer exception occurs when user close the ImagePlus windows and
continue working anyway. My ByteProcessor instance is not null but sudently,
Null pointer error occurs in ij.process.ByteProcessor.putPixel method or any
other ByteProcessor method using Pixel[] array field. A quick debug showed
that this array is null since ImagePlus is closed although my ByteProcessor
is still not null.

Is-it a normal behaviour ? How can I troubleshoot my pb ?

Thanks

----------------------------------------
Eddie Iannuccelli
Laboratoire de génétique cellulaire
INRA - Castanet Tolosan
Tel: 05 61 28 54 44 / Fax: 05 61 28 53 08
Reply | Threaded
Open this post in threaded view
|

Re: ByteProcessor class pixel[] fieldl become NULL when closing associated ImagePlus windows

Wayne Rasband
> My plugin write some annotations into a ByteProcessor displayed
> in an ImagePlus (I use putPixel,drawString methods, etc.).
> My annotated ByteProcessor instance is stored as a field in a
> dedicated class so I can display it again and again in a new
> ImagePlus window if user unfortunatly close current image (I don't
> know how to prevent user closing ImagePlus windows ;).
>
> The null pointer exception occurs when user close the ImagePlus
> windows and continue working anyway. My ByteProcessor instance,
> is not null but sudently Null pointer error occurs in
> ij.process.ByteProcessor.putPixel method or any other ByteProcessor
> method using Pixel[] array field. A quick debug showed that this
> array is null since ImagePlus is closed although my ByteProcessor
> is still not null.
>
> Is-it a normal behaviour ? How can I troubleshoot my pb ?

ImageJ sets the pixel arrays to null when the window is closed to  
encourage garbage collection. You can prevent this from happening by  
making a setIgnoreFlush(true) call on each new ImagePlus you create.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: ByteProcessor class pixel[] fieldl become NULL when closing associated ImagePlus windows

Eddie Iannuccelli
Problem solved !
Thank you very much wayne

> -----Message d'origine-----
> De : ImageJ Interest Group [mailto:[hidden email]] De la
> part de Rasband Wayne
> Envoyé : samedi 1 juillet 2006 03:18
> À : [hidden email]
> Objet : Re: ByteProcessor class pixel[] fieldl become NULL
> when closing associated ImagePlus windows
>
> > My plugin write some annotations into a ByteProcessor
> displayed in an
> > ImagePlus (I use putPixel,drawString methods, etc.).
> > My annotated ByteProcessor instance is stored as a field in a
> > dedicated class so I can display it again and again in a
> new ImagePlus
> > window if user unfortunatly close current image (I don't
> know how to
> > prevent user closing ImagePlus windows ;).
> >
> > The null pointer exception occurs when user close the ImagePlus
> > windows and continue working anyway. My ByteProcessor
> instance, is not
> > null but sudently Null pointer error occurs in
> > ij.process.ByteProcessor.putPixel method or any other ByteProcessor
> > method using Pixel[] array field. A quick debug showed that
> this array
> > is null since ImagePlus is closed although my ByteProcessor
> is still
> > not null.
> >
> > Is-it a normal behaviour ? How can I troubleshoot my pb ?
>
> ImageJ sets the pixel arrays to null when the window is
> closed to encourage garbage collection. You can prevent this
> from happening by making a setIgnoreFlush(true) call on each
> new ImagePlus you create.
>
> -wayne
>