On Mar 19, 2007, at 4:47 PM, Keith DeLong wrote: >> Questions? You ask 'em, I'll answer 'em. >> >> Cheers, >> - Joe > > I asked a question at the end of the 'Difference between Destructor > and > Close in a RectControl subclass' thread on March 7 but you may have > not seen > it. I've long pondered an issue on Windows and object scope in > REALbasic: > > Say I have 'dim w as new Window2' in the action event of a push > button in > window1. When I run the project and push the button, Window2 opens as > expected. However, Window1 continues to exist after the completion > of the > method. Normally I would expect that as the local variable w goes > out of > scope at the end of the method (and lacking any other references) > Window2 > would cease to exist as well. Why not?
Because REALbasic hangs onto a reference to the window -- presumably the one returned by the Window function -- until Window.Close is called. This method destroys the underlying OS object and removes the global reference to the window. If there are no other references to the (REALbasic) Window object, the object is then destroyed. To illustrate, consider the following code. dim w as new Window1 w.Close at this point, (Window(i) is w) will evaluate to false for any value of i. But w itself is not nil. The Window1 object still exists, and you can access its methods and properties, though most of them won't do much because the controls on the window are long gone. Charles Yeomans _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
