Path: utzoo!attcan!uunet!wuarchive!rex!mandel@vax.anes.tulane.edu From: mandel@vax.anes.tulane.edu (Jeff E Mandel MD MS) Newsgroups: comp.sys.mac.programmer Subject: Re: Common (fatal) problem with DialogManager plus a solution Message-ID: <5665@rex.cs.tulane.edu> Date: 14 Jan 91 14:29:04 GMT References: <1991Jan2.073359.12067@uniwa.uwa.oz> <47962@apple.Apple.COM> <1991Jan11.002919.12966@dartvax.dartmouth.edu> Sender: news@rex.cs.tulane.edu Organization: Tulane University School of Medicine Lines: 35 In article <1991Jan11.002919.12966@dartvax.dartmouth.edu> ari@eleazar.dartmouth.edu (Ari Halberstadt) writes: >Summary > >A method to crash many application programs using the dialog manager >is outlined, several solutions are discussed, and finally a code >fragment illustrates a solution which may be incorporated into your >own programs. > [Much stuff] > >Possible Solutions > >Search for the resources needed by the dialog or alert before you call >the dialog manager. This is tricky: you have to be sure to look for >all the resources. For instance, if the dialog includes a control >template, you have to make sure the control exists. If the dialog >needs a picture, you have to make sure the picture exists, etc. etc. >This information is stored in various resources, especially the 'DITL' >for the dialog. You'll need to write code which knows all sorts of >intimate details about the formats of resources. Programmers really >shouldn't have to muck around with such things. > I work in C++, and have been writing a lot of XCMDs, where you have the added problem of being a guest in someone else's house. My solution is that I have a class for a dialog within an XCMD, and a generic dialog item class with subclasses for things like editable text, lists, popup menus, etc. The initializer (not the constructor, as it cannot report back failure) for each of these preflights for existence of the needed resources. It took me only a short time to write these routines, and now I just blithely write code knowing clever people cannot crash me. I know that writing robust code is not something most people start out doing, but the tools are there. I personally have written code for a real-time closed loop controller that administered a potentially lethal drug to human beings; you had better believe that I assured myself that some creative user couldn't pop out a floppy and crash that puppy!