Path: utzoo!attcan!uunet!munnari!castan From: castan@munnari.oz (Jason Castan) Newsgroups: comp.sys.mac.programmer Subject: Re: cdev/Control Panel bug or undocumented action? Summary: dialogptr in cdev, closeDev Message-ID: <2279@munnari.oz> Date: 8 Aug 88 00:57:49 GMT References: <611@kinetics.UUCP> Organization: Comp Sci, Melbourne Uni, Australia Lines: 26 In article <611@kinetics.UUCP>, buzz@kinetics.UUCP (Mahboud Zabetian) writes: > I am writing a cdev and noticed a funny behaviour when a closeDev message was > encountered. It seems as if the value of CPDialog is not valid. If I do a > GetCtlValue, the item is not found and a bus error occurs.(I do add numItems to > the number of my item). > > For instance, in the following code, a beep is sounded on a deActivDev, but > none for a closeDev: > > case closeDev: > GetDItem(CPDialog, MANBUTTON + numItems, &itemType, &ctrl, &box); > if (GetCtlValue(ctrl)) > SysBeep(9); By the time you get the closeDev message, the dialogptr might already have been disposed. Therefore it is never valid to actually do anything with CPDialog in 'case closeDev'. What you have to do is check the ctrl value during nulDev. I got stung by this myself ! One last thing about debugging the control panel. Version 3.0 had lots of subtle bugs that were corrected in 3.3 (?), the latest distributed in release 6.0. Its worth keeping a copy of the old CP if you are writing a cdev, as i dont think any programmer should be lazy and assume that everyone will be using the latest system. john lim