Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!ogicse!cs.uoregon.edu!mkelly From: mkelly@cs.uoregon.edu (Michael A. Kelly) Newsgroups: comp.sys.mac.programmer Subject: CDesktop::RemoveWind Message-ID: <1990Dec20.070612.21903@cs.uoregon.edu> Date: 20 Dec 90 07:06:12 GMT Sender: news@cs.uoregon.edu (Netnews Owner) Organization: Department of Computer Science, University of Oregon Lines: 50 I've found a possible bug in CDesktop. The procedure RemoveWind is: void CDesktop::RemoveWind( CWindow *theWindow) /* Window object to remove */ { if (theWindow->IsVisible()) { HideWind(theWindow); /* Hide window before removing it */ } itsWindows->Remove(theWindow); } If this procedure removes the last window from the desktop, the CDesktop instance variable 'topWindow' should go to NIL, shouldn't it? It doesn't; it remains whatever it was before the call. I encountered this problem by making this call from a document: gApplication->itsDirectors->DisposeItems(); gDesktop->topWindow remained the same after the call. This eventually caused a crash, since the window had been disposed of. I changed RemoveWind to void CDesktop::RemoveWind( CWindow *theWindow) /* Window object to remove */ { if (theWindow->IsVisible()) { HideWind(theWindow); /* Hide window before removing it */ } itsWindows->Remove(theWindow); if ( itsWindows->numItems == 0 ) topWindow = NULL; } This has apparently fixed the problem, since the program no longer crashes. So, was the problem with CDesktop, or am I not doing something correctly? Also, is there a way to make a window completely ignore clicks other than overriding CDesktop::DispatchClick ? Thanks, Mike. -- Michael A. Kelly | "Fish heads, fish heads, Internet: mkelly@cs.uoregon.edu | Roly-poly fish heads, America Online: Michael792 | Fish heads, fish heads, Compu$erve: 73567,1651 | Eat them up, yum!" - Barnes & Barnes