Unless I am wrong I can't see any point of passing a file argument to the save method as you are actually saving the document to itself.
Only situation where it could make sense is when the document has been converted (i.e opening a template, idml or a former version).
But then you wouldn't catch a "path" as they would be new documents.
But to give your crashes some meaning, maybe this explains it all. As you are trying to rewrite the file onto itself, maybe windows has some underlaying mechanisms that makes indesign crashing.
Once again, save() without argument should do.
Im not saving the document to the same path. Its two different paths. It works just fine on macintosh, but not on windows.
Its 184.108.40.206 x64, running on Windows 7 Enterprice, servicepack 1.
There are some cases where you need to save to the same path. If you open a CS6 dokument in CC and then try to save the document
using the norrmal save command you get a Save As dialog. That is something I would like to avoid because the customer should not have to find the correct place to save the document. The plugin should take care of that.
Yes I think we agree on the main idea. Most likely crashes occur when some operation cannot be resolved. The fact it works with an alert might show that the file cannot be written at some point. Using an alert adds a delay that may free the file for further writing operations. I got a script long ago where a routine would work fine on mac all the time but would work only once on windows. After that you had to quit and relaunch indesign to get it working again…once. On the second attempt, Windows claimed for files permissions…
So in your case, you might try to add a $.sleep() command before the save. Maybe a 200ms delay might solve the issue. Maybe it won't especially if the file is located onto a server with a low bandwith network.
Other solution might be to save to a temp location, close the doc, remove the original file and then relocate the temp file to the genuine location. I know this kind of tricks don't make much sense but still if it can solve your issues.
Thanks for taking the time to help me.
I solved it the following way:
I do a saveACopy to the correct filepath.
Close the open doc, and open the correct doc that I did the saveACopy to.
I will try the $.sleep solution, and hope it works. Its a lot nicer solution.