Copy link to clipboard
Copied
The simple code below causes inDesign to crash if I open two documents, switch between them and try to close one.
#targetengine "session"
app.addEventListener("afterActivate", activateHandler);
function activateHandler(ev){
alert(ev.target.constructor.name);
}
An error also occurs if I add EventListener on Document or LayoutWindow
Have you any idea about it?
I just want to do something if another Document or LayoutWindow is selected/activated
Hi IronPaw ,
will it work, if you do not alert target of event, but protocol all property/value pairs of event in the JavaScript Console of the ESTK like that? :
#targetengine "session"
app.addEventListener("afterActivate", activateHandler);
var counter = 0;
function activateHandler(ev)
{
try
{
for(x in ev)
{
$.writeln( counter +"\t"+ x +"\t"+ ev
.toString() ); };
}
catch(e)
{
$.writeln( counter +"\t"+ x +"\t"+ e.message ) ;
};
counter++
};
Th
...Copy link to clipboard
Copied
What is your exact version of InDesign and OS ?
Regards,
Uwe
Copy link to clipboard
Copied
Process: Adobe InDesign CC 2018 [2374]
OS Version: Mac OS X 10.13.3 (17D47)
Copy link to clipboard
Copied
Hi IronPaw ,
will it work, if you do not alert target of event, but protocol all property/value pairs of event in the JavaScript Console of the ESTK like that? :
#targetengine "session"
app.addEventListener("afterActivate", activateHandler);
var counter = 0;
function activateHandler(ev)
{
try
{
for(x in ev)
{
$.writeln( counter +"\t"+ x +"\t"+ ev
.toString() ); };
}
catch(e)
{
$.writeln( counter +"\t"+ x +"\t"+ e.message ) ;
};
counter++
};
The above code is working for me without crashing InDesign CC 2018.
I'm on Mac OS X 10.11.6
Regards,
Uwe
Copy link to clipboard
Copied
You are absolutely right. I remove the alert from the handler and the code works correctly!
The bad habit of using alert appeared after work on my MacBook Pro Retina...
I do not know why but ExtendScript Toolkit runs on it is very bad: freezes/stops sometimes the icon shows that the program is open and the program window is not found anywhere
Thank you, Uve. You help me a second time.
Copy link to clipboard
Copied
Interesting. A simple alert should not crash InDesign.
Still, I did not test the version with the alert…
Speed of ExtendScript Toolkit app is an issue on its own.
Don't know if that's possible on OS X 10.13., but Gregor Fellenz once successfully disabled App Nap on OS X to speed up the ESTK: Re: ID CC 2014 plus ExtendScript (Yosemite) slow to the point of not working...
For me on OS X 10.11.6 it's working as expected.
Regards,
Uwe
Copy link to clipboard
Copied
Maybe alert leads to InDesign Crash because when the alert request is made, Indesign is busy with some internal operation.
Sometimes that would be worth the try is evaluating the type of the event and see if it's type of a document.
Would the following snippet crash too ?
#targetengine "session"
app.addEventListener("afterActivate", activateHandler);
function activateHandler(ev){
var doc = ev.parent;
if ( !(doc instanceof Document) return;
alert(doc.constructor.name);
}
Copy link to clipboard
Copied
Hi Loic,
just tested the initial code with InDesign CC 2018 13.0.1.207.
No crashes so far. Even when adding, closing (event fires) or changing focus (event fires) to new additional layout windows for a document. Maybe the reason for a crash is "elsewhere"? Maybe another script is running in the same target engine or a 3rd-party plug-in is interfering?
FWIW: At hilfdirselbst.ch we recently had a case where a plug-in by Rorohiko was crashing InDesign when an event script was running that was looking for "afterSelectionChanged" event in conjunction with a ScriptUI dialog:
https://www.hilfdirselbst.ch/foren/Interaktives_Panel_P562510.html#562510
Regards,
Uwe
Copy link to clipboard
Copied
Forgot: My tests were done on OS X 10.11.6. OS and InDesign is German.
Regards,
Uwe
Copy link to clipboard
Copied
Good to know. Indeed, that would be a valuable explanation. It's likely some bright mind can make sense of the crash reports and see where the issue came from.