Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!keith From: keith@Apple.COM (Keith Rollin) Newsgroups: comp.sys.mac.programmer Subject: Re: MacApp v2.0b5 problem / ModalDialogs Message-ID: <33429@apple.Apple.COM> Date: 24 Jul 89 21:09:37 GMT References: <1169@sequent.cs.qmc.ac.uk> Organization: Apple Computer Inc, Cupertino, CA Lines: 44 In article <1169@sequent.cs.qmc.ac.uk> stathis@cs.qmc.ac.uk (Stathis Gikas) writes: >Hi there, > >I'm developing a User Interface for a configurable >messaging system, whose semantic layer is implemented in C and >runs on a Sun, while its syntactic layers (UI) run on a number >of (different types of) remote hosts. >The syntactic layer talks to the semantic >layer via remote procedure cals. I'm coding the Mac UI. > >The Problem: Sorry for deleting the problem, but it was rather lengthy. Essentially, it concerned calling PoseModally and then crashing. The problem here has to do with a variable called gEventLevel. This variable is used to determine the nesting level for calls to PollEvent. If it is set to 1, then we are supposed to be at the outer level, and a call to UnloadAllSegments is triggered to clean up memory. Normally, a call to PoseModally will call PollEvent, which bumps gEventLevel to something greater than 1, does the event stuff, and then decrements the level. In this situation, UnloadAllSegments is not called. HOWEVER, if MacApp is creating the initial untitled document, it does so before the main event loop is ever entered. At this point, gEventLevel is still set to zero. The first call to PoseModally and PollEvent set this to 1, the segments are unloaded, and the segment that called PoseModally gets moved in memory. Returning to it essentially returns to garbage. This has been fixed in MacApp 2.0b9 (now available from APDA). In the meantime, you may want to increment and decrement gEventLevel around your call to PoseModally. >buy you a drink :-) OK! ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. --- Developer Technical Support INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions