Photoshop not responsive after a Script

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

undavide

Photoshop not responsive after a Script

Post by undavide »

Hello,
I'm having an issue with a ScriptUI window, which is part of a more complex script (my testing platform is Mac, CS6).

As long as I leave the Window as 'dialog' everything's fine (basically the user interact with it, some filtering is applied on the active document, then the window closes). But I need it to be non-modal (that is: a 'palette') so I came up with the following workaround:

Code: Select allvar isDone = false
var myWin = function () {
  // window stuff
}
myWin.prototype.run = function () {
  // ...
  this.windowRef.show()
   while (isDone === false) { waitForRedraw() }
}

Of course I set isDone = true in the Apply / Cancel buttons.onClick() functions, and I've no need to explicitly call the .close() function because when the waitForRedraw() stops being called, it closes anyway.

So far so good, apparently, but after the script is properly done and the Window closed, Photoshop is quite not responsive: a click on the "eye" in the Layers palette to toggle a layer's visibility makes the layers thumbnails and part of the Layers palette itself to briefly disappear, I can't select any Tool in the Tools palette (or at least it takes way too much time between the click and the actual tool selection), I can't leave Photoshop but with a forced quit, and so on and on.

I've tried substituting waitForRedraw() with app.refresh(), but it gives me issues with the Navigator Palette display (in my script I turn PS fullscreen hiding the palettes but the Navigator)

Has that ever happened to you? I've wondered whether some loop could be going on in spite of the apparent end of the process, but it looks like a weird option (this came to my mind because my laptop fans keeps spinning without any reason - I mean, Photoshop is idle). Is there any way to force garbage collection, to quit any process triggered by the script run, to make the thing not disturb Photoshop after it's done?!
Thanks so much for your suggestions!

Davide

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

undavide

Photoshop not responsive after a Script

Post by undavide »

Got it
FYI, an infinite loop can go ahead indefinitely (by definition...) even if you're given back the control of Photoshop.
In my case (which is far more complex that the example I've posted) the variable isDone was changed within a conditional that was never reached - and not where needed. The result is that a while (true) {waitForRedraw} was going on even after the apparent end of the script, causing of course a lot of troubles.