Icy-imaging / Icy-Kernel

Icy kernel module
http://icy.bioimageanalysis.com/
55 stars 16 forks source link

Icy Exit #631

Closed aghand0ur closed 9 years ago

aghand0ur commented 9 years ago

Hi,

When I call "Icy.exit(bool)' inside the ScriptEditor plugin, the script stops execution but Icy is not closed. I expected this function once called to cause Icy GUI to close.

Any suggestions on this regard?

Stephane-D commented 9 years ago

Hi,

I tested and it seems you can't directly do that as when you call Icy.exit(..) all Plugin will receive an event to close properly. It's why you receive a message from the Script Editor to close the current script... the problem is that if you accept to close, the Script engine will actually kill itself while it's still executing the exit instruction... I got the script working by modifying it like this :

importClass(Packages.icy.system.thread.ThreadUtil)
importClass(Packages.icy.main.Icy)

var r = new java.lang.Runnable()
{ 
    run: function()
    {
        // safe to wait a bit
        ThreadUtil.sleep(500)
        Icy.exit(false)
    } 
};

ThreadUtil.bgRun(r)

I also modified a bit the script editor plugin for better close operation handling but in the current case it does not make a real difference.

aghand0ur commented 9 years ago

Thanks Stephane. The script you suggested works perfectly :) :+1:

Stephane-D commented 9 years ago

You're welcome :)