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 Development Framework / Documentation / Development Notes / TroubleShooting / Runtime Assertions < prev   
Encoding:
Text File  |  1996-09-17  |  19.2 KB  |  285 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                      
  5. Runtime Assertions 
  6. ODF Release 2                                                                                                                                                             
  7.  
  8.  
  9. This document shows the most common assertions you might encounter. Each entry in this document lists the library, file, method, and a short explanation of the assertion.
  10.  
  11.                                                                                                                                                                                      
  12. Can't register a class as archivable if it doesn't have RTTI                                            
  13.  
  14. Library:       ODFFoundation
  15. File:             FWArDyna.cpp
  16. Method:      FW_CPrivArchiver::AddNameToLabelPair
  17.  
  18. Explanation:  This error should never happen if you're using native RTTI.  If you're using ODF RTTI, then you've forgotten to use the FW_DECLARE_CLASS and FW_DEFINE_CLASS_Mx macros for a class that is being registered as archivable. If you get this error you'll need to figure out which class is being registered for archiving.  Since the RTTI isn't available it's not possible to get a class name string, but the four character class label is available.  You'll need to get that information using a debugger.
  19.  
  20.  
  21.                                                                                                                                                                                      
  22. If an initialize function is registered, a destroy function must be too.                          
  23.  
  24. Library:        ODFFoundation
  25. File:              FWArDyna.cpp
  26. Method:      FW_SPrivArcFun::FW_SPrivArcFun
  27.  
  28. Explanation: Archivable classes can use one-step or two-step initialization.  Classes that use one-step initialization use just the "create" function, and do not use an "initialize" function (a NULL pointer is passed to the FW_REGISTER_ARCHIVABLE_CLASS macro).  If an initialize function is specified, the class is using two-step initialization.  Two-step initialization is a potential source of a resource-leak if an exception is thrown by the initialization function.  To prevent this leak, it is necessary to provide a destroy function to destroy the object created by the "create" function.  You'll get this assertion if you've specified a non-NULL value for the initialize function but specified NULL for the destroy function.
  29.  
  30.  
  31.                                                                                                                                                                                      
  32. Object registry ID was not found in registry                                                  
  33.  
  34. Library:       ODFFoundation
  35. File:             FWArDyna.cpp
  36. Method:      FW_CPrivArchiver::PrivCreateObject
  37.  
  38. Explanation: If the above assertion fails, the most likely explanation is that some data read from the stream is not in sync with some data written to the stream. Another potential problem is that the stream contains a reference to an object that was supposed to be preregistered at runtime, but for some reason wasn't. This can be checked by using a debugger.  Was the object ID returned by the object registry a negative value? Finally, a last possibility is that the stream of data has been corrupted in some other way.
  39.  
  40.  
  41.                                                                                                                                                                                      
  42. <Class Label ID> class not registered for archiving. Forgot FW_DO_NOT_DEAD_STRIP ?
  43.  
  44. Library:       ODFFoundation
  45. File:             FWArDyna.cpp
  46. Method:       ClassLabel_Create
  47.  
  48. Explanation: A class label ID was encountered in a stream for which no class has been registered.  Either you forgot the FW_REGISTER_ARCHIVABLE_CLASS macro, or the translation unit containing it wasn't linked into your part editor.  This might happen due to dead-stripping by the linker.  You can prevent dead-stripping of archivable classes using the FW_DO_NOT_DEAD_STRIP macro.  Call the macro for the archivable class from some function that you know will not be dead-stripped.  One such place is your part's Initialize method.  
  49.  
  50. In particular if you create views from resources remember to use FW_DO_NOT_DEAD_STRIP for all the view classes which are not referenced in your code.  You can call it in your frame's PostCreateViewFromStream method as ODF samples do.
  51.  
  52. Note: in the current version you may see an assertion message containing garbled characters between the 4 characters class label and the string "class not registered for archiving...", just ignore these characters.
  53.  
  54. The following table lists the class labels and corresponding view and menu classes defined by ODF:
  55.  
  56.   Label   Class
  57.  
  58.   bscl     FW_CPrivBaseScroller
  59.   butn     FW_CButton
  60.   edvw     FW_CEditView
  61.   gpbx     FW_CGroupBox
  62.   grbx     FW_CGrowBox
  63.   lbox     FW_CListBox
  64.   mnit     FW_CMenuItem
  65.   picv     FW_CPictSView
  66.   popm     FW_CPopupMenu
  67.   pdmn     FW_CPullDownMenu
  68.   rcls     FW_CRadioCluster
  69.   sbsc     FW_CScrollBarScroller
  70.   scbr     FW_CScrollBar
  71.   sclr     FW_CScroller
  72.   seit     FW_CSeparatorItem
  73.   stxt     FW_CStaticText
  74.   suit     FW_CSubMenuItem
  75.   tgit     FW_CToggleItem
  76.   txit     FW_CTextItem
  77.  
  78.                                                                                                                                                                                      
  79. No registered archiving functions for class label
  80.  
  81. Library:       ODFFoundation
  82. File:             FWArDyna.cpp
  83. Method:     FW_CPrivArchiver::PrivCreateObject
  84.  
  85. Explanation: Under normal circumstances this assertion could only happen if the "<Class Label ID>' class not registered for archiving. Forgot FW_DO_NOT_DEAD_STRIP ?" assertion had already been triggered.  If you see this assertion and did not see the "Forgot FW_DO_NOT_DEAD_STRIP?" assertion, please report a bug to the ODF team.  See above for more information about this problem.
  86.  
  87.  
  88.                                                                                                                                                                                      
  89. Attempt to create object from stream with NULL create function
  90.  
  91. Library:       ODFFoundation
  92. File:             FWArDyna.cpp
  93. Method:      FW_CPrivArchiver::PrivCreateObject
  94.  
  95. Explanation: The archiving subsystem allows you to pass a NULL pointer in the place of the "create" function parameter.  However, if the archiver encounters a class label ID for such a class while reading from a stream then it will be unable to create the object.
  96.  
  97.  
  98.                                                                                                                                                                                      
  99. Class <className> has already been registered as archivable!
  100.  
  101. Library:       ODFFoundation
  102. File:             FWArDyna.cpp
  103. Method:      FW_CPrivArchiver::AddNameToLabelPair
  104.  
  105. Explanation: You probably used the FW_REGISTER_ARCHIVABLE_CLASS macro twice for the same class.  If you want to register previous versions of the class, use the FW_REGISTER_PREV_VERSION_ARCHIVABLE_CLASS macro.
  106.  
  107.  
  108.                                                                                                                                                                                      
  109. Exception error, calling terminate()
  110.  
  111. Library:       ODFFoundation
  112. File:             FWExcImp.cpp
  113. Method:       DoTerminate
  114.  
  115. Explanation:  This message appears only if a problem occurs and you're using ODF exceptions, but the problem can happen with either native or ODF exceptions.  One way the problem can occur is to throw an exception inside a scope for which there is no active try block.  This might happen if you've created a SOM class and you implement one or more methods without a try block (ODF uses try blocks for all of its SOM entry points).
  116.  
  117.  
  118.                                                                                                                                                                                      
  119. Why is an autodestruct object of class <classname> being constructed in a bad context?  See FWExcImp.cpp for possible causes.
  120.  
  121. Library:       ODFFoundation
  122. File:             FWExcImp.cpp
  123. Method:      FW_AutoConstructed
  124.  
  125. Explanation: Possible causes:
  126.      1) The autodestruct object is a member of another object, which itself is not an autodestruct object. This other object is being allocated via new, not FW_NEW.  If so, this is a programmer error. Make the other object's class be autodestruct, and use FW_NEW.
  127.      2) This is a static object of a shared library that has just been loaded, and static constructors are being executed.  We have attempted to detect this condition and not report it as an error, but may not have eliminated it for all environments.  If this is the case, it is not a programming error.  You can safely continue execution. Note: if you move this code into an application (as opposed to a shared library), you may need to set FW_gInStaticInit to zero in your main() to inform this subsystem that static initialization is complete.
  128.      3) A case similar to 2) is possible.  If a static autodestruct object is declared in a function, the compiler is not obligated to initialize it at static initialization time. It can (and should) wait until the function is first called.  This case is very difficult to detect (without help from the compiler!).  It is not a programming error, and it is safe to continue excecution.
  129.      4) You are using threads and did not call FW_Thread_NoteSwitch when threads were switched.
  130.  
  131.  
  132.                                                                                                                                                                                      
  133. The autodestruct class <classname> is missing an FW_END_CONSTRUCTOR.
  134.  
  135. Library:       ODFFoundation
  136. File:             FWExcImp.cpp
  137. Method:      FW_AutoDestructed
  138.  
  139. Explanation: An FW_START_DESTRUCTOR is executing for a class that was constructed without an FW_END_CONSTRUCTOR.  Look at every constructor of the class <classname> and make sure it has an FW_END_CONSTRUCTOR.  Don't forget that the compiler might generate a copy constructor for you if you haven't declared one.  If you declare a class to be autodestruct, the compiler generated copy constructor  will not work; you must provide your own definition for the copy constructor.  Note that a compiler will also generate a default constructor, but only if you haven't declared any constructors.
  140.  
  141.  
  142.                                                                                                                                                                                      
  143. An autodestruct class is missing an FW_END_CONSTRUCTOR or FW_START_DESTRUCTOR. Likely candidates: <class1> and <class2> respectively.
  144.  
  145. Library:       ODFFoundation
  146. File:             FWExcImp.cpp
  147. Method:      FW_AutoDestructed
  148.  
  149. Explanation: This is similar to the message above, but it is a slightly different case, and harder to pinpoint at runtime.  The error is probably a missing FW_START_DESTRUCTOR in class2's destructor, but it may be a missing FW_END_CONSTRUCTOR in one of class1's constructors.
  150.  
  151.  
  152.                                                                                                                                                                                      
  153. The autodestruct class <classname> is missing an FW_START_DESTRUCTOR
  154.  
  155. Library:       ODFFoundation
  156. File:             FWExcImp.cpp
  157. Method:      FW_PrivTryBlockContext_Destroy
  158.  
  159. Explanation: A try block is going out of scope, but an autodestruct object of class <classname> in the try block's scope didn't clean up after itself by calling FW_START_DESTRUCTOR in its destructor.  Find the destructor of the class (classname::~classname) and add the FW_START_DESTRUCTOR macro as the first line of the destructor. 
  160.  
  161.                                                                                                                                                                                      
  162. FW_CFixedAllocator: An object of type <classname> has not been deleted properly.
  163.  
  164. Library:       ODFOS
  165. File:             FWFixMem.cpp
  166. Method:       FW_CFixedAllocator::~FW_CFixedAllocator
  167.  
  168. Explanation: FW_CInkRep, FW_CStyleRep, FW_CFontRep, and FW_CPatternRep are allocated using a pool allocation scheme. This assertion indicates that one of these objects was not disposed when the allocator for the objects was disposed, indicating a possible memory leak. This situation can arise if you allocate a FW_CInk, FW_CStyle, FW_CFont or FW_CPattern object on the heap, instead of on the stack, and forgot to delete it. You may also have one of these objects as a field of another object that you are not disposing correctly.
  169.  
  170.  
  171.                                                                                                                                                                                      
  172. Environment has non-OpenDoc error
  173.  
  174. Library:       ODFOS
  175. File:             FWODExce.cpp
  176. Method:       FW_GetEvError
  177.  
  178. Explanation: Don't know what to do, the “Environment” variable contains a non-OpenDoc error.
  179.  
  180.  
  181.                                                                                                                                                                                      
  182. FW_CMenuItem::Read should never have been called
  183.  
  184. Library:       ODFOS
  185. File:             FWAMnuIt.cpp
  186. Method:       FW_CMenuItem::Read
  187.  
  188. Explanation: ODF is trying to instantiate a FW_CMenuItem, which is an abstract base class. This could be the result of an error in your menu resource.  In particular you may have left an extra comma after the last  menu item (ODFRC doesn't catch this error at compile time).
  189.  
  190.  
  191.                                                                                                                                                                                      
  192. Trying to set the Facet Part Info of a non-display facet
  193.  
  194. Library:       ODFOS
  195. File:             FWFctInf.cpp
  196. Method:       FW_SetFacetRefCon
  197.  
  198. Explanation: FW_SetFacetRefCon was called with a facet parameter that was not a display facet. ODF uses the facet's PartInfo field to store information about the device. A part is not allowed to set the PartInfo field of a non-display facet.
  199.  
  200.  
  201.                                                                                                                                                                                      
  202. Failed to load menu resource
  203.  
  204. Library:       ODFOS
  205. File:             FWMnuBar.cpp
  206. Method:       FW_CMenuBar::InitializeFromResource
  207.  
  208. Explanation:  We use a try-catch block purely to warn about a common mistake. If you forget to add the resource containing your menus to your project, or specify the wrong menu resource ID, the code will throw an exception that probably won't get caught until the SOM entry point from OpenDoc. OpenDoc will display an error dialog that isn't particularly helpful in diagnosing the problem.
  209.  
  210.  
  211.                                                                                                                                                                                      
  212. Your view or frame is not a FW_MReceiver, or you forgot RTTI macros
  213.  
  214. Library:       ODFFramework
  215. File:             FWControl.cpp
  216. Method:       FW_CControl::InitializeFromStream
  217.  
  218. Explanation:  If you get this error:
  219.                 1)  Make sure that you are linking this control to a view or frame that inherits from FW_MReceiver.
  220.                 2)  Make sure that you use the RTTI macro FW_DEFINE_CLASS_Mx, as in the following example:
  221.                                         FW_DEFINE_CLASS_M2(MyFrame, FW_CFrame, FW_MReceiver)
  222.         (See also ODF samples)
  223.  
  224.  
  225.                                                                                                                                                                                      
  226. in FW_MEventHandler::PrivInsert, handler already inserted
  227.  
  228. Library:       ODFFramework
  229. File:             FWEventH.cpp
  230. Method:       FW_MEventHandler::PrivInsert
  231.  
  232. Explanation:  FW_MEventHandler::AdoptEventHandler() was called twice with the same event handler. An event handler cannot adopt another event handler more than once.
  233.  
  234.  
  235.                                                                                                                                                                                      
  236. Can't call SetLocation on a FW_CFrame
  237.  
  238. Library:       ODFFramework
  239. File:             FWFrame.cpp
  240. Method:      FW_CFrame::SetLocation
  241.  
  242. Explanation:  You cannot call SetLocation on a view of type FW_CFrame because it is the root view of your frame (i.e. its location is always 0, 0). 
  243.  
  244.  
  245.                                                                                                                                                                                      
  246. The part info resource is missing
  247.  
  248. Library:       ODFFramework
  249. File:             FWPart.cpp
  250. Method:       FW_CPart::Initialize
  251.  
  252. Explanation:  All ODF parts must have a Part Info resource. You either forgot to include the resource in your project or passed the wrong ID to the FW_CPart constructor.
  253.  
  254.  
  255.                                                                                                                                                                                      
  256. Cannot use a ScrollBarScroller here, create a separate content view
  257.  
  258. Library:       ODFFramework
  259. File:             FWScrolr.cpp
  260. Method:       FW_CScrollBarScroller::PrivCheckFrame
  261.  
  262. Explanation: ODF doesn't allow a frame to use a scroller with scroll bars if the frame does not have a content view. Without the content view, the scroll bars will end up moving with the rest of the frame's content!  A frame that is its own content view can only use a basic FW_CScroller object. The frame's content can be scrolled with mechanisms such as hand-scrolling or auto-scrolling.
  263.  
  264.  
  265.                                                                                                                                                                                      
  266. Failed to load view resource.
  267.  
  268. Library:       ODFFramework
  269. File:             FWSView.cpp
  270. Method:       FW_CSuperView::CreateSubViewsFromResource
  271.  
  272. Explanation:  We use this try-catch block purely to warn about a common mistake. If you forget to add the resource containing your views to your project, or specify the wrong view ID, the above code will throw an exception that probably won't get caught until the SOM entry point from OpenDoc. OpenDoc will display an error dialog that isn't particularly helpful in diagnosing the problem.
  273.  
  274.                                                                                                                                                                                      
  275. preferredKind != NULL
  276.  
  277. Library:       ODFFramework
  278. File:             FWPart.cpp
  279. Method:       FW_CPart::PrivDeterminePreferredKind
  280.  
  281. Explanation:  You may get this error when opening stationery.  It means that you created the stationery before installing the ODFLibrary. You need to install the ODF Library, and recreate stationery before proceeding.
  282.  
  283.  
  284. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  285. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.