Running a script from process container

Mike1485

Well-known member
The following is a very short script that does nothing except prepare to process a view and then decide not to do anything. Not very interesting but it pairs my question down to its essentials.

#include <pjsr/UndoFlag.jsh>

function doNothingOn(view)
{
view.beginProcess(UndoFlag_DefaultMode);
view.endProcess();
}

function main()
{
/*******************************************************************************
* View context
*******************************************************************************/
if (Parameters.isViewTarget)
{
doNothingOn(Parameters.targetView);
return;
}

/*******************************************************************************
* Global context
*******************************************************************************/
if (Parameters.isGlobalTarget)
{
let warnMessage = "Script cannot execute in global context";
let msgReturn = (new MessageBox( warnMessage, "Warning", StdIcon_Warning, StdButton_Ok )).execute();
return;
}

/*******************************************************************************
* Direct context
*******************************************************************************/
var view = ImageWindow.activeWindow.currentView;
doNothingOn(view);
}

main();



This code can be run either directly or from a script instance. If the script instance is dropped into a process container and then the process container is dragged across to an image this works fine too. But, if the process container also contains another process, eg a Histogram Transformation instance, then the script fails with the following error message:

*** Error [000]: /Users/michaelcranfield/Desktop/TestFile.js, line 5: Error: Invalid view update request: The image is already being processed: imageId

If the undo flag is changed to UndoFlag_NoSwapFile, then everything works fine which leads me to think that the problem lies with the swap file generation. Can anyone shed any light on this and on whether there is a way round this issue?

Many thanks for any help.
 
Back
Top