Path: utzoo!utgpu!water!watmath!clyde!bellcore!faline!thumper!ulysses!andante!princeton!udel!gatech!ncar!ames!pasteur!ucbvax!decwrl!nsc!voder!apple!tecot From: tecot@apple.UUCP Newsgroups: comp.sys.mac.programmer Subject: Re: Bug in System 6.0, or is it ME? Message-ID: <13832@apple.Apple.COM> Date: 13 Jul 88 01:31:16 GMT References: <1988Jun22.110349.325@mntgfx.mentor.com> <13112@apple.Apple.COM> <1988Jul5.112217.267@mntgfx.mentor.com> Reply-To: tecot@apple.apple.com.UUCP (Ed Tecot) Organization: Apple Computer Inc, Cupertino, CA Lines: 40 In article <1988Jul5.112217.267@mntgfx.mentor.com> tomc@mntgfx.mentor.com (Tom Carstensen) writes: >I didn't thing you could expect that a Disposed of handle or pointer would >be NULL (or NIL) ??? Should Apples code go something like this: > > TEDispose(hTE); > hTE = NULL; > . . . > . . . > if (hTE != NULL) TEDispose(hTE); I tried to simplify my description of the problem. Having failed that, I will go into the long-winded approach: The Dialog Manager uses TextEdit in a wierd way. The net effect of this was that instead of calling TEDispose, it called DisposHandle. The reason this was done was because the Dialog Manager had already trashed the text handle. The new TextEdit includes style information and if TEDispose was not called, it would leave lots of orphans around, wasting memory. A patch was made to DisposHandle in the following manner: if (Dialog Manager is giving me a TextEdit handle) { teH->textH = NewHandle(0); TEDispose(teH); } else call real DisposHandle; MacNosy discipline uses the following patch: call real DisposHandle; if (handle == DIRTY) then UserBreak; else handle = DIRTY; This breaks when TEDispose reenters DisposHandle. If Steve had written reentrant code he wouldn't have had a problem: if (handle == DIRTY) then UserBreak; else { call real DisposHandle; handle = DIRTY; } _emt