djvelleman@amherst.bitnet (10/23/90)
Last week I posted a question about calling SystemTask or GetNextEvent with thePort not set to a legal GrafPort. The more I think about this, the more concerned I am about potential problems. Suppose I close a window and then call DisposeWindow to dispose of the window record. If that window was the current grafport, won't thePort now be invalid? If I return to the main event loop without doing something about this, will my program crash? I know many people don't dispose of window records when they close windows, but surely lots of people call DisposDialog when they're done with a dialog. Won't this cause the same problem? Perhaps my diagnosis of my bug was wrong, but I don't think so. At any rate, setting the port to a valid grafport before going to the main event loop stopped the program from crashing. What's the official policy on setting thePort before calling SystemTask or GetNextEvent? What's the official policy on disposing of window records? Has anyone else had a problem with this? Dan Velleman Math Dept. Amherst College
pepke@gw.scri.fsu.edu (Eric Pepke) (10/26/90)
In article <10804.272420f5@amherst.bitnet> djvelleman@amherst.bitnet writes: > What's the official policy on setting > thePort before calling SystemTask or GetNextEvent? What's the official > policy on disposing of window records? Has anyone else had a problem with > this? I don't know what the "official" policy on setting the current GrafPort is, but one should set it to a known good port once every time through the event loop, EVEN IF one's program is otherwise perfectly consistent with GrafPorts. The reason for this is that you don't know what desk accessories are doing behing your back. (Yes, I know that they are by default not loaded in the same partition under MultiFinder, but somebody will do it.) Now, some desk accessories have bugs which cause them to dispose of windows without setting the current GrafPort correctly. Some have bugs which cause them to call one of the QuickDraw routines that require a valid current GrafPort without setting it first. Either will work fine with most programs, but when somebody runs both of these desk accessories under your program, KABOOM! You can be sure that the resulting shrapnel will be blamed on your program, so play it safe. Eric Pepke INTERNET: pepke@gw.scri.fsu.edu Supercomputer Computations Research Institute MFENET: pepke@fsu Florida State University SPAN: scri::pepke Tallahassee, FL 32306-4052 BITNET: pepke@fsu Disclaimer: My employers seldom even LISTEN to my opinions. Meta-disclaimer: Any society that needs disclaimers has too many lawyers.