Skip to main content
Inspiring
February 12, 2024
Answered

InDesign crashed when trying to create the TOC programmatically

  • February 12, 2024
  • 2 replies
  • 550 views

Hi all, I need some help. 

 

We have developed a plugin for InDesign and it tries to create a TOC using a TOC style which is already there in the document.

 

InterfacePtr<ICommand> myCreateTOCCmd(CmdUtils::CreateCommand(kCreateTOCCmdBoss));

if (myCreateTOCCmd == nil) {

    break;

}

 

InterfacePtr<IStringListData> myStringList(myCreateTOCCmd, UseDefaultIID());

if (myStringList == nil) {

break;

};

InterfacePtr<ITOCCmdData> myCmdData(myCreateTOCCmd, IID_ITOCCMDDATA);

if (myCmdData == nil) {

break;

};

 

//set myStringList and prepare myCmdData

 

myErr = CmdUtils::ProcessCommand(myCreateTOCCmd);

 

When I try to process command, instead of returning an error, indesign crashes. The exception thrown is

"Exception thrown at 0x00007FFB9256D26C (Text.rpln) in InDesign.exe: 0xC0000005: Access violation reading location 0x0000000000000000."

 

I tried using InDesign Debug version and right before the crash it gave me this message. 

"About to use nil interface ptr! Queried IID was IID_IMARGINS, on Boss kSplineItemBoss."

 

How can I identify the cause of the crash?

This topic has been closed for replies.
Correct answer Chamari_Silva

Thank you for the reply. I found out that it can be the placePoint that causes the problem.

2 replies

Robert at ID-Tasker
Legend
February 13, 2024

Have you tried with a different document? Maybe this one is corrupted?

 

Can you try IDMLing to fix it?

 

Inspiring
February 13, 2024

Yes. It's hapenning only with a single document. I found out that it can be the placePoint that causes the problem. Thank you for the reply.

Inspiring
February 13, 2024

Hi @Chamari_Silva ,

 

Creating TOC is not that straight forward.

 

You need to share your complete code to analyze where is the problem. -

 

//set myStringList and prepare myCmdData

 

- Rahul Rastogi

InDesign SDK C++ Custom Plugin Architect

Chamari_SilvaAuthorCorrect answer
Inspiring
February 13, 2024

Thank you for the reply. I found out that it can be the placePoint that causes the problem.