Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!iuvax!bsu-cs!mithomas From: mithomas@bsu-cs.bsu.edu (Michael Thomas Niehaus) Newsgroups: comp.sys.mac.programmer Subject: What's wrong with this picture? Keywords: dereferencing, crash, reasons Message-ID: <8263@bsu-cs.bsu.edu> Date: 18 Jul 89 04:36:32 GMT Organization: CS Dept, Ball St U, Muncie, IN, USA Lines: 37 Can someone tell me why this section of code causes problems: CreateNew() { extern int i; extern StructHandle test[]; /* This is a dummy name. The structure contains a field called theWindow which points to the window for this record. */ test[i] = (StructHandle) NewHandle( sizeof(StructHandle) ); HLock(test[i]); (**(test[i])).theWindow = GetNewWindow(130, 0 , -1); HUnlock(test[i]); } It appears to work OK, but my inDrag routine suddenly started crashing when I implemented this: any time I click in the drag region, it bombs. I first thought that the dereferencing was causing problems, so I put in the HLock. Then I thought maybe I needed more master handles. So I did that in the initialization module. Still no luck. (By the way, this is Lightspeed C, and looking at the debugger leads me to believe that the window in properly initialized -- no nil values.) If I change the code to assign the WindowPtr to some temporary variable before I store it in the structure, I don't seem to have any problems. Thanks for any advice. -Michael -- Michael Niehaus UUCP: !{iuvax,pur-ee}!bsu-cs!mithomas Apple Student Rep ARPA: mithomas@bsu-cs.bsu.edu Ball State University AppleLink: ST0374 (from UUCP: st0374@applelink.apple.com)