ID crashes when call method "createHyperlinkQRCode" on Rectangle from "afterOpen" event handler
ID 18.1 Windows 10
I'm trying to develop a script that updates the QR code (creates anew in the same Rectangle ) when the document is opened.
The Startup Script sets the event handler of the "afterOpen" event, where the "createHyperlinkQRCode" method is called on the found Rectangle object.
In this case, InDesign crashes with an error
<crash exception="EXCEPTION_ACCESS_VIOLATION" exceptionCode="0xc0000005" instruction="0x00007FFD49229914">
Creating a QR code manually through the main menu does not cause errors. The error does not occur when the script calls the "createHyperlinkQRCode" method on the Document object. But in this case, I have to point with the cursor to the place of inserting the QR code, and this creates an unnecessary waste of time.
If the script is called from the script panel, it works without errors, which indicates that there are no errors in the script.
I tried the following layouts (they cause the same error and crash InDesign):
(1) Preferred option. Call the QR code creation method directly in the "afterOpen" event handler.
(2) I extended the Rectangle object with an additional method that is called in the "afterOpen" event handler.
(3) I made a separate script that can be run manually. It works if I run it manually. And crashes if I call this script in the "afterOpen" event handler using doScript().