avoid automatic "save changes" dialog in a plug-in

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

avoid automatic "save changes" dialog in a plug-in

Agnès Sauleda Brossa
Hi everybody,

I'm writing a plug-in and the way I use to close windows I don't need
anymore is:

imp.getWindow().close();  where imp is an ImagePlus

this happens to display a dialog asking if I want to save cahnges in images.
What do I have to do to avoid this dialog? I don't need to save the changes.

thanks,

Agnès
Reply | Threaded
Open this post in threaded view
|

Re: avoid automatic "save changes" dialog in a plug-in

Wayne Rasband
> I'm writing a plug-in and the way I use to close windows
> I don't need anymore is:
>
> imp.getWindow().close();  where imp is an ImagePlus
>
> this happens to display a dialog asking if I want to save cahnges
> in images. What do I have to do to avoid this dialog? I don't need
> to save the changes.

Use

     imp.changes = false;
     imp.getWindow().close();

Note that this method generates an exception if your plugin as called
from a macro running in batch mode. With ImageJ 1.36 and later, you can
use

     imp.changes = false;
     imp.close();

which does not have this problem.

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

Re: avoid automatic "save changes" dialog in a plug-in

Agnès Sauleda Brossa
Thanks a lot!

2006/3/24, Wayne Rasband <[hidden email]>:

>
> > I'm writing a plug-in and the way I use to close windows
> > I don't need anymore is:
> >
> > imp.getWindow().close();  where imp is an ImagePlus
> >
> > this happens to display a dialog asking if I want to save cahnges
> > in images. What do I have to do to avoid this dialog? I don't need
> > to save the changes.
>
> Use
>
>     imp.changes = false;
>     imp.getWindow().close();
>
> Note that this method generates an exception if your plugin as called
> from a macro running in batch mode. With ImageJ 1.36 and later, you can
> use
>
>     imp.changes = false;
>     imp.close();
>
> which does not have this problem.
>
> -wayne
>
Reply | Threaded
Open this post in threaded view
|

Re: avoid automatic "save changes" dialog in a plug-in

Albert Cardona
In reply to this post by Agnès Sauleda Brossa
Agnes,

Just set the 'changes' field in the ImagePlus to false.

Albert