Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!aplcen!samsung!usc!apple!apple.com!goldman From: goldman@apple.com (Phil Goldman) Newsgroups: comp.sys.mac.programmer Subject: Re: DA questions, the second time around... Message-ID: <6014@internal.Apple.COM> Date: 4 Jan 90 18:51:32 GMT Sender: usenet@Apple.COM Organization: Apple Computer Lines: 60 References:<68060@tiger.oxy.edu> <33466@ucbvax.BERKELEY.EDU> In article <33466@ucbvax.BERKELEY.EDU> oster@dewey.soe.berkeley.edu (David Phillip Oster) writes: > In article <68060@tiger.oxy.edu> sonenbli@oxy.edu (Andrew D. Sonenblick) writes: > >I have many a DA which are utilities which must be loaded into the > >application heap (so they can be assured of communication with the appl). > >No biggie, option down on opening the DA. Ok, but I also *need* the > >DA's to be closed upon quitting the applications they reside in. > The DA will receive a goodbye kiss if any of the following is true: - The driver handle is in the app heap - The driver's storage handle (dce->dCtlStorage) is in the app heap - The driver's window ptr (dce->dCtlWindow) is in the app heap The idea here is that only drivers that have memory allocated in an app heap need to know when that app quits. I suppose it may be possible to have other memory allocated per app, but in that case one of the conditions above should be true also, to guarantee correct behavior. Note that the case that is *not* supported well is the system driver that has multiple app clients, for each of which it must maintain state. Such a driver would like a goodbye kiss when *any* app quits. The problem is that goodbye kisses do not translate well into the multitasking world. The original gb kiss meant that the app was expiring, but it also implied that the entire world was disappearing, since only one app ran at a time, and drivers were (often) loaded in the app heap. Therefore, for compatibility reasons, as usual, MF only gives gb kisses to drivers for which the world truly is going away -- those that have some type of storage in the particular app heap. What is needed is a "global gb kiss". The only other alternatives are for the driver to remain stateless (the best, if possible), timeout on state, or patch _ExitToShell. > I, too, had this problem in the "Flips" desk accessory that is shipped in > Scott Kim's "Letterforms & Illusions" product. This product has close to > 100 paint files of Kim's beautiful calligraphic puzzle art, a demo version > of MacPaint, and my desk accessory that adds new commands to macpaint for > file traversal, and exploring symmetries of rotation and reflection. > > I solved the problem by installing a head patch on ExitToShell that, when > triggered, attempts to remove my patches. It sounds like you should just Font/DA move your DA into MacPaint, if it is the only app it is used for. You will get the gb kiss when MacPaint quits. Thus, you can avoid the _ExitToShell patch altogether. > I checked, applications _can_ exit via a return from main(), without > directly calling ExitToShell(). But, if they try, the O.S. executes an > ExitToShell() for them. _ExitToShell will *always* be called when an app quits under MF, even if it does so because of a _SysErr. This is not true of UniFinder, because _Launch may terminate an app. as well. -Phil Goldman Apple Computer