I have an event associated with textframe on text update, inside this event I delete the textframe using the same code from the samples provided but Indesign crashes after deleteing the text, if I deleted the textframe from other place (the event on the menu for example) I don't face any problem.
Thanks in advance.
I'm not sure what you mean with "on text update". Do you remove the text frame while InDesign is still busy with them?
A way to get into safe waters is to schedule your changes for later execution, e.g. using the appropriate call in CmdUtils.
I mean with "on text update" that I have an observer class attached to the TextFrame inside it I implemented the Update method, inside this method i use the CmdUtils::CreateCommand(kDeleteCmdBoss) and process the command using CmdUtils::ProcessCommand.
After that Indesign crashes.
How do you attach your observer to the text frame? Did you use the AddIn mechanism of the object model - that would be very unusual.
Otherwise, on what boss is your observer, and what change (protocol) are you observing, from what subject?
Anyway, let me repeat my suggestion to have a second look at CmdUtils, search for "schedule" there ...