Sorry if it was asked before, I did try to google it first. Also, this is my first post on this forum, so apologies if I do not follow some rules and do tell me if it is the case.
The original post with more details is here: extendscript - InDesign crashing when opening a file from the book - Stack Overflow
In short, I am creating a book and creating and adding chapters. After saving the book, any attempt to touch the files through the script results on InDesign crash.
Environment: Mac OSX 10.9.5 InDesign CS5.5, ExtendScript
If I run this code:
I can see the alert pops up and the book on the background is still open. When I OK the alert box, the book starts closing. If I add any following script steps after the alert, they seems to be done before the book is saved/closed.
I tried so far:
Extract from crash report:
Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x00000040 ebx: 0x00000040 ecx: 0x00000040 edx: 0x00000000
edi: 0xbfffac54 esi: 0x00000040 ebp: 0xbfffab88 esp: 0xbfffab70
ss: 0x00000023 efl: 0x00010282 eip: 0x947d6bd5 cs: 0x0000001b
ds: 0x00000023 es: 0x00000023 fs: 0x00000000 gs: 0x0000000f
Logical CPU: 0
Error Code: 0x00000004
Trap Number: 14
Could anyone push me into the right direction? Any thoughts will be appreciated.
Sorry, I've realised it is impossible to answer this without looking at the other parts of the code.
After a lengthy investigation I am now looking at a particular area: saving files inside a loop
I am opening template, load data from the database and save the file into the book folder, close file and move on to the next one
app.activeDocument.save(myFolder.fsName + "/" + filename +".indd");
If I stop the script at this point (between two loop iterations) and check the folder, I can see that on the first save *.idlk file is created. When the document is closed the *.idlk file stays there, locking the file for edit. The file is added to the book later on the script. Any operations at a later stage crash InDesign.
I tried to run the script with ESTK and it behaves differently - on document close() the lock file disappears. Closing document with different options does not help.
If I pause script at the end of file creation loop and manually remove lock files - the script works absolutely fine.
I tried to reference *.idlk files and remove them through the script - again, it works fine.
This feels like a workaround and I am missing something. Does anyone has any advice on how to avoid file locks when closing a file?