Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!hsdndev!dartvax!Roger.W.Brown From: Roger.W.Brown@dartmouth.edu (Roger W. Brown) Newsgroups: comp.sys.mac.hypercard Subject: Re: External Windows and Activate event Message-ID: <1991Jun14.172804.8368@dartvax.dartmouth.edu> Date: 14 Jun 91 17:28:04 GMT References: <78140@brunix.UUCP> Sender: news@dartvax.dartmouth.edu (The News Manager) Organization: Dartmouth College, Hanover, NH Lines: 35 In article <78140@brunix.UUCP> Andrew_Gilmartin@Brown.EDU writes: > However, if you call SendCardMessage() during an activate or > deactivate event HyperCard crashes. I can't be real explicit about this without seeing the code, but it sounds like a reentrancy problem. Have you enabled reentrancy? If so, you need to be prepared for it whenever you do a call back that could cause your XCMD code to be rentered. SendCardMessage and EvalExpression are two to be careful of. The easiest way to handle renetrancy is to save a copy of the paramPtr on the stack (ie. in avariable local to the currently executing procedure) before doing the callback and restore it afterwards. If you keep a global copy of the paramPtr around, it is likely to be wrong after the callback, so you have to restore it to what it was. It works like this: the XCMD gets called with an activate event and it stores a copy of the paramPtr globally. The XCMD calls back to HyperCard. HyperCard sends a null event or something else back to the XCMD during the callback. The XCMD stores the paramPtr for that call globally, in the same location that it used on the preceding call that has not yet completed. Then the first call continues with the wrong paramPtr. That might not be the problem and it might not be clear, but it may give you an idea of where to look. Roger W. Brown Courseware Development Dartmouth College Hanover, NH Roger.W.Brown@dartmouth.edu