Path: utzoo!attcan!uunet!samsung!usc!apple!agate!shelby!portia!jessica!rick From: rick@jessica.Stanford.EDU (Rick Wong) Newsgroups: comp.sys.mac.programmer Subject: Re: MacApp help needed (closing a window) Message-ID: <11061@portia.Stanford.EDU> Date: 11 Apr 90 17:25:21 GMT References: <90099.091150DN5@psuvm.psu.edu> <40173@apple.Apple.COM> <435@psych.psy.uq.oz> Sender: USENET News System Organization: Academic Information Resources Lines: 17 Another possible cause of your problem is that you may be trying to free the window while one (or more) of its methods is still executing. In par- ticular, the window's mouse-handling method may be calling your button's mouse-handling method. If closing the window frees it and its document, any still-executing methods of any freed objects will be left referring to invalid objects. If they subsequently try to change any no-longer- existent fields, they will whomp over random parts of memory, thus causing a crash. To work around this, you can set a global flag indicating the window should be closed. You can periodically check this flag in your application's DoIdle method, where you should be able to safely free the window and its document. Or, you could wait for the PostCommand mechanism in some forth- coming version of MacApp. Rick "no snazzy .signature" Wong rick@jessica.stanford.edu