>>Big Snip........
>>>>ENDDEF
>>>>
>>>>*--------- End BugDemo.Prg
>>>
>>>Thanks for your code. Unfortunately, I could not repro the crash. In fact, when I click at the WAIT WINDOW line, I get an error:
>>>
>>> PARENT is not an object
>>>
>>>on line:
>>>
>>> THIS.Parent.Children = THIS.Parent.Children - 1
>>>
>>>What happens if you SET RESO OFF? Can anyone else repro this crash?
>>
>>
>>Hi Randy,
>>
>>I'm sorry if I was not clear, when I say crash, I mean program crash, not 'end of the world VFP crash'.
>>
>>The 'PARENT is not an object' is the problem. During the Destroy event of an Object I would expect the parent reference to still be valid. This is certainly the case in VFP 5 as the same code runs with no problems.
>
>
>OK. Here is the scoop. This is not a bug. You can't reference this.parent in the Destory method of an object that has been removed. Make the following changed the program to make this work properly...
>
>* in the KillItems procedure, change to use...
>
>PROCEDURE KillItems
>_SCREEN.Menu.Tools.Add.Report.Release
>_SCREEN.Menu.Tools.Add.Remove.Release
>
>
>* in the SubDemo class, change to use...
>
>PROCEDURE Destroy
>? "KILL " + THIS.Name
>ENDPROC
>
>PROCEDURE Release
>? "RELEASE " + THIS.Name
>THIS.Parent.Children = THIS.Parent.Children - 1
>THIS.Parent.RemoveObject(THIS.Name)
>ENDPROC
Thanks for the quick response.
But, the error ocurrs in the Destroy event for the 'Remove' object, which is in fact the second of the two objects being explicitly released by the KillItems subroutine. Therefore the destroy code has already run sucessfully for the 'Report' object.
I am sure that I have used the Parent reference in the destroy method of an object in VFP 3 and 5 previously.
This following simple example runs fine in VFP 6 as I would expect.
*-- Start Ex2.Prg
_SCREEN.AddObject("Test", "Fred")
_SCREEN.RemoveObject("Test")
DEFINE CLASS fred AS Custom
PROCEDURE Destroy
? THIS.Parent.Class, THIS.Parent.Name
ENDPROC
ENDDEFINE
*-- End Ex2.Prg
I would really appreciate any further comments.