Much of this material, except for code examples, has been incorporated into the OpenDoc Programmer's Guide for the Mac OS, published by Addison-Wesley.
When debugging, a common question is "what should the refcount of my part be?" Parts, Frames, Shapes and Transforms are the objects developers will most care about when it comes to reference counting. This note gives examples of simple documents that shows what the correct refcount of objects should be. If you are getting errors or warnings because of improper refcounts, check your objects against these examples to make sure you are doing the right thing.
In most cases, Shapes and Transforms stored in Frames or Facets should have a reference count of 1, so they are omitted from the examples shown below.
A Single Part
This example shows a document with a single root part and no embedded parts. Note that no allowance is made for any foci, such as for the SelectionFocus if this part were active. See the next example for the effect of foci.
A Single Active Part
This example shows a document with a single root part and no embedded parts. In this case, the part is active, so it has acquired several foci for its display frame. Each focus increases the refcount of the frame by one.
One Embedded Part
This example shows a document with a root part and one embedded part. Each embedded frame effectively increases the refcount of the containing frame by one.
Active Embedded Part
This example shows a document with a root part and one embedded part which is active. Each focus acquired by the part for its frame increases the reference count of the frame by one.