Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!decwrl!asente From: asente@decwrl.dec.com (Paul Asente) Newsgroups: comp.windows.x Subject: Re: R4 Athena Widget question. Message-ID: <2928@bacchus.dec.com> Date: 28 Feb 90 22:23:33 GMT References: <9002261658.AA28416@expo.lcs.mit.edu> <1990Feb24.002324.14813@agate.berkeley.edu> <1990Feb26.192750.15430@agate.berkeley.edu> Organization: DEC Western Software Lab Lines: 32 In article <1990Feb26.192750.15430@agate.berkeley.edu> spanki@color.ced.berkeley.edu (Frank Goodman) writes: ...a bunch of stuff berating the MIT applications for ust exiting instead of destroying their widgets... When you write a non-toolkit program that uses malloc, do you explicitly free all of the allocated storage before you exit? Of course you don't. You know that malloc doesn't consume any system resources that won't be recovered when you program exits. This places some future constraints on malloc (that it *never* be changed to consume resources that need explicit freeing) but it's considered a reasonable tradeoff not to have to do a whole slew of completely useless work before you exit the program. The situation with widgets is completely analogous. If a widget consumes a resource that needs explicit freeing, the widget documentation had better document this so that the application can be sure to destroy the widget before exiting. Otherwise there is no point in having the program spend time freeing storage, destroying windows, freeing fonts and graphics contexts, and so forth when these things would all be done automatically (and much more quickly) if the application just exits. The destroy methods and callbacks are mostly for applications that need to continue after destroying some or all of their widgets. The toolkit was not designed to require or encourage explicit destruction in normal cases; the preferred way to exit an application has always been to call exit. We could have made things more convenient for the cases where a particular kind of widget needs to be destroyed, but the current scheme of setting a flag and writing your own event loop is not difficult to program and works just fine. -paul asente asente@decwrl.dec.com decwrl!asente