Home |
Rules Of Memory Ownership Obtaining a Pointer to PegPresentationManager Determining the Position of an Object |
Rules Of Memory OwnershipWhen an RTPEG-32 object is added (i.e. attached) to another object, RTPEG-32 owns that object. You do not have to worry about deleting that object as long as you have passed it on to RTPEG-32. RTPEG-32 ensures that all children of an object, along with the object itself, are deleted when the parent object is closed. For example, suppose you create a dialog window using the new memory allocation operator. After creating the dialog, you also create a dozen or so controls and add them to the dialog. At this point all of the controls are owned by the dialog. All that you need to do to delete all of the allocated memory is delete the dialog. Next, assume that you add the dialog to PegPresentationManager (i.e. the dialog is now visible). At this point, you have given up all ownership of the dialog and the dialog's child controls. RTPEG-32 is now responsible for insuring that the dialog and its child controls are deleted from memory when the dialog is closed. Finally, assume that you manually Remove() the dialog from PegPresentationManager, without allowing the dialog to close itself in response to user input. In this case, you again own the dialog, because PegPresentationManager no longer has any knowledge of the dialog's existence. However, the controls which were added to the dialog are still owned by the dialog, so once again all that needs to be done to delete all memory associated with the dialog and its controls is to delete the dialog.
|