Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Collection with multiple refs to the same object - Bug
Message
 
 
To
28/10/2003 12:33:35
Matthias Will
BiCON Systemtechnik GmbH
Karlsruhe, Germany
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00843625
Message ID:
00843855
Views:
20
Hi Matthias,

It think it's a bug (dangling object reference). The following code shows it w/o using the debugger. The form is released only after CLEAR ALL.
CLEAR
o = CREATEOBJECT('Collection')
o2 = CREATEOBJECT('_Form')
o.Add(o2,'First')
o.Add(o2,'Second')
o2 = Null
? "Before:", o.Count   && 2
o.Item(1).Release()
? "After:", o.Count    && 0
? "CLEAR ALL"
CLEAR ALL
RETURN   
*-------------------------
DEFINE CLASS _Form AS Form
    PROCEDURE Init AS VOID
        ? PROGRAM(), TIME()
    ENDPROC
    PROCEDURE Destroy AS VOID
        ? PROGRAM(), TIME()
    ENDPROC
ENDDEFINE
>Hi all,
>
>today I went into some strange behavior - I isolated it to the collections garbage collection. Lets have a class with a "Release This" in one of its methods - Form ie provide this - to see if its Destroy() was fired, it creates a public variable in the Init() and releases it in Destroy() :
>
>DEFINE CLASS _Form AS Form
>    PROTECTED PROCEDURE Init AS VOID
>        PUBLIC gbIamHere
>        DODEFAULT()
>    ENDPROC
>    PROTECTED PROCEDURE Destroy AS VOID
>        Release gbIamHere
>        DODEFAULT()
>    ENDPROC
>ENDDEFINE
>
>Now do this :
>
>o = CREATEOBJECT('Collection')
>o2 = CREATEOBJECT('_Form')
>SET STEP ON * now we see the gbIamHere var in debug-window
>o.Add(o2,'First')
>o.Add(o2,'Second')
>
>o2.Release()
>SET STEP ON * -> o2 = .NULL.;o.Count = 0 this should be so, BUT gbIamHere is still visible -> Destroy has not fired -> internal dangling object-reference
>
>Because I wanted a collection to save same references with different keys this is really annoying !
>We should call this a bug, shouldn't we ?
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform