I have an old ExtendScript script, which creates a dialog, where users can insert some arguments, etc.
...
// This is the method that creates the window and displays it
window.buttons.run.onClick = function () {
window.close(1);
};
window.buttons.cancel.onClick = function () {
window.close(2);
};
window.defaultElement = window.buttons.run;
window.cancelElement = window.buttons.cancel;
var result = window.show();
return result;
}
// Then in the main function
var result = createWindow();
if (result !== 1) {
return;
}
// Do some heavy work
but, occasionally, the script runs but the window doesn’t fully close. More specifically, I don’t see the window elements, like buttons, texts, etc., anymore, I see only the window with a blank/white background and the title. See the screenshot below.
Moreover, this blank dialog remains open all the time until I force close photoshop. The script execution continues and even finishes, but the window remains opened.
I suspect that this behaviour is due to the fact that close() doesn’t actually block, so the window may not be fully closed and cleaned once it returns.
What’s the best solution to solve this problem?
I think that calling $.sleep() is bad solution because it’s really a hack and how many ms I need to sleep may not always be the same. I don’t even know if calling it would actually solve this issue. Is there a better solution?
This issue doesn’t always happen, but I don’t want it to happen ever, as this script is used by other people, and this is annoying.
