home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / Developer Documentation / Recipes, Tech Notes & Articles / Tech Notes / Normal Refcounts < prev    next >
Encoding:
Text File  |  1996-07-19  |  1.7 KB  |  84 lines  |  [TEXT/ttxt]

  1. What should my refcount be?
  2.  
  3. Copyright Â©1995, 1996 Apple Computer, Inc.
  4.  
  5. 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.
  6.  
  7. 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.
  8.  
  9. 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.
  10.  
  11. A Single Part
  12.  
  13. 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.
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. A Single Active Part
  28.  
  29. 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.
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. One Embedded Part
  47.  
  48. 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.
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. Active Embedded Part
  64.  
  65. 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.
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.