Scripting: Photoshop crashes when I try to close dialog windows sequentially
I have a script that provides for editing parameters in a separate dialog box. This window provides 2 options for closing - close only the edit window and return to the parent and close both windows (parent and edit window) - this functionality is needed for the next part of the script to work. If the user himself controls the state of the windows by dialog buttons, then there are no problems with sequential closing of windows.
However, I have a problem if I try to initiate the opening and closing of a window inside a function: in certain cases, the script should be run immediately in edit mode (i.e., the parent window should be shown first, and then the edit window). In this case, the user can also decide to close both windows - in that case when i trying to close the child window first, then the parent window, Photoshop crashes (this happens in all new versions).

The easiest way to demonstrate this effect is with the following code:
var d = new Window ('dialog')
d.onShow = function ()
{
var d1 = new Window ('dialog')
var b = d1.add('button', undefined, 'close both windows')
b.onClick = function () {d1.close (-1)}
if (d1.show () == -1) d.close ()
}
d.show ()
Is there any other way to create two windows at once when script starts, and then by clicking one button close both of them?
