Skripting, undo: I gt an Error i dont understand
In the following simplified code I get the error that "the last command could not be undone".
Anyone knows WHY I get this error?
QGlobalSemaphores = [];
// ECMAScript 3 has no classes
function WaitForIt(callback, object) {
this.object = object;
this.answer = null;
this.index = -1;
this.callback = callback;
}
function doSubscript(index) {
mySemaphore = QGlobalSemaphores[index];
mySemaphore.callback(mySemaphore.object);
alert("executed");
}
function executeSubscript(callback, object) {
var w = new WaitForIt(callback, object);
w.index = QGlobalSemaphores.push(w) - 1;
app.doScript(doSubscript,ScriptLanguage.JAVASCRIPT,[w.index],UndoModes.FAST_ENTIRE_SCRIPT,'FE-Test');
}
function deleteLayers(obj) {
var doc = app.activeDocument;
var i = doc.layers.length;
while (i-->1) {
doc.layers[i].remove();
}
}
function test() {
executeSubscript(deleteLayers, null);
app.undo(); // <-- I get the error here.
}
app.doScript(test,ScriptLanguage.JAVASCRIPT,[],UndoModes.ENTIRE_SCRIPT,'Callback-Test');
