dlyons@Apple.COM (David Lyons) (09/12/89)
In article <8909110041.ab12957@SMOKE.BRL.MIL> V112PDL5@UBVMSC.CC.BUFFALO.EDU writes: >I just finished reading the technotes for NDA design guidelines. I get the >impression that tools that the NDA must start up itself can only be activated >when the NDA is the front window. That is, when the NDA's window is activated. >Is this correct? If so what happens when the NDA receives an update event to >draw it's content when it is not the front window, and the refreshing requires >the Font Manager or QDAux? Buffering the window could take a lot of memory. > > - Mark Cromwell (Mark is referring to Apple IIgs Technical Note #53, "Desk Accessories and Tools," March 1989.) The whole topic is Interesting and Weird, and one of these days I'm going to take that 4-page note and make it into something Much Larger. As the note stands, most of what it says is Good, but it doesn't go into enough special cases in detail. The safest approach is even more restrictive than what the note suggests. To be really safe, every time your NDA gets control, it should make whatever changes to the environment are necessary, and it should put things back how they were *before returning control to the system*. This means, for example, starting and shutting down QD Aux every time your DAInit, DAOpen, DAClose, or DAAction procedure is called, if you need to call QD Aux and it isn't already started up. (For some toolsets, this approach is not workable. Starting the Font Manager every time you get control would be silly: it would do a fair amount of disk access every time. I don't know of a completely safe way to use the Font Manager from an NDA, if the application hasn't started it.) The keep-my-extra-tools-started-while-my-window's-in-front approach will work a lot of the time, but the application's main event loop is still running in the NDA-modified environment, and the user can choose Application menu items. Let's see how that can toast you: KeenApp is running, and it doesn't load Standard File until it *needs* to. KoolDA gets opened and decides to start up Standard File, keeping it started whenever its window is in front. With KoolDA still in front, the user chooses KeenApp's Open... item, and KeenApp goes LoadOneTool(stdfile), SFStartUp(...), and (being a typical half-way Polite, half-way stupid application) KeenApp notices the "Standard File already started" error and calls SysFailMgr. Presto--you're toast. (Solution for Standard File: If it isn't started, start it, use it, and shut it back down.) BTW, QD Aux seems pretty harmless at first glance, but you can toast yourself with that, too. If you start it up and leave it started, an application that can switch between 640- and 320- mode using the method recommended in Apple IIgs Technical Note #4 will do a QDShutDown and a QDStartUp. QDAux works closely with QD, and you *must* do QDAuxShutDown before QDShutDown, and QDAuxStartUp after QDStartUp, if you're using QDAux. Otherwise you're toast. ----- Does somebody want to take bets on how many pages long I can make that Technote? :-) I need to get it written in about the next 3 weeks to make the next batch, so get your suggestions in now. I also plan to address using Resources from NDAs (it's really very simple until you try it :-). BTW, if you're sick of seeing the word "toast," send me your favorite alternative phrases for toastiness. I'll collect them. -- --Dave Lyons, Apple Computer, Inc. | DAL Systems AppleLink--Apple Edition: DAVE.LYONS | P.O. Box 875 AppleLink--Personal Edition: Dave Lyons | Cupertino, CA 95015-0875 GEnie: D.LYONS2 or DAVE.LYONS CompuServe: 72177,3233 Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons My opinions are my own, not Apple's.