I have a global variable that points to a class PerotinApp that is a subclass of the class wxApp (part of the wxWidgets open source package). This class is the "holder" for basically everything associated with the application itself. In the wxApp class there is virtual function called MacHandleAEODoc(). I have overridden this function in the PerotinApp class.
One of the first things the initialization code does is "new" one of these classes to keep in the global variable. Immediately after that the Apple Event handlers are initialized.
Normally all of this works fine, when the app is open it gets an open document apple event, the handler gets called, it in turn calls the MacHandleAEODoc() function and the document is opened correctly. On any system except the Intel Mac when the app is closed everything also works. In fact, if the very first time the app is run you start it by sending an Open Document Apple Event everything works correctly.
However, on an Intel Mac after the first time the app is run a very odd thing happens. Instead of the handler calling the PerotinApp's MacHandleAEODoc() function the wxApp's MacHandleAEODoc() function is called. In fact, if I try to force the call to the PerotinApp's function with a dynamic_class(theWxApp)->MacHandleAEODoc() the app actually crashes on an access violation at address 0.
My guess is that the virtual function table isn't set up for the subclass and the wrong function is called because it think's there's no override or "code" at 0x0 is called because the virtual function table isn't properly initialized. I was hoping maybe someone had seen something similar and had some ideas on what I might do to overcome this problem.
FreeHand Systems, Inc.