Objective Views : Chapter 12 Commands : Components in a Command
Components in a Command
Every command keeps a list of pointers to the components it affects. These components are reference counted, so they cannot be deleted from memory before all the commands are done using them. For example, if the user selected a component and deleted it, the component would still be referenced by the delete command even though it is no longer in the model. If the component was deleted when it was removed from the model, the command would have a bad pointer to it. If the user tried to undo the delete command, the program would crash. Because the components are reference counted, the component would remain in memory as long as the delete command was around.