Script.scriptEnding not triggered when script is reloaded


#1

This can cause some problems. A scriptEnding signal should probably be sent before the script is executed again.


#2

Posted this as a suggestion on worklist


#3

It looks like Script.scriptEnding will trigger once when reloaded but after that it will no longer fire.

Try to reload this multiple times and it will only print once.

function scriptStopped()
{
print(“script stopped”);
}

Script.scriptEnding.connect(scriptStopped);

Furthermore, if you try to stop a script that runs another copy of itself upon stopping, it crashes interface when you try to stop it. It will also spawn multiple versions of itself when you reload all.

var thisScript = “http://foo.com/scripts/bar.js”;

function scriptStopped()
{
Script.load(thisScript);
}

Script.scriptEnding.connect(scriptStopped);

It is hard to explain what is going on here because the results are strange and unexpected.

Unstoppable scripts are one thing (and probably a good thing to have) but unstoppable scripts that crash interface are probably undesirable.