Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP6 and Object Destruction.
Message
From
22/01/1999 04:58:12
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, United Kingdom
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00177849
Message ID:
00178863
Views:
47
>>I can reproduce the error in my complex code every time, but I will try to produce a simpler version for reporting to MS. I think, as you said, it will not be easy to reproduce in a simple program.
>
>If you can send me a file or two, that would be great.
>
>Thanks...
>
>Randy [msft]

Hi Randy,

Here's a demo that highlights my problem in VFP 6 only. It runs fine in VFP5.
The code models my OO menu system, which is why it's a little convoluted.

The problem seems to occur when the EXECUTE method is invoked. This calls the KillItems subroutine which has two lines of code, one problem is that VFP returns to the EXECUTE method after the first line of KillItems has executed.

Anyway, here's the code. I look forward to your comments.

*------------- Start BugDemo.Prg
*-- This mimics the creation of a hierarchy of menu objects
CLEAR
_SCREEN.AddObject("Menu", "MainDemo")
_SCREEN.Menu.AddObject("File", "SubDemo")
_SCREEN.Menu.AddObject("Edit", "SubDemo")
_SCREEN.Menu.AddObject("View", "SubDemo")
_SCREEN.Menu.AddObject("Tools", "SubDemo")
_SCREEN.Menu.AddObject("Help", "SubDemo")

_SCREEN.Menu.File.AddObject("Exit", "SubDemo")

_SCREEN.Menu.Edit.AddObject("Copy", "SubDemo")

_SCREEN.Menu.View.AddObject("Data", "SubDemo")

_SCREEN.Menu.Tools.AddObject("Test1", "SubDemo")
_SCREEN.Menu.Tools.AddObject("Test2", "SubDemo")
_SCREEN.Menu.Tools.AddObject("Add", "SubDemo")
_SCREEN.Menu.Tools.AddObject("Test3", "SubDemo")

_SCREEN.Menu.Help.AddObject("About", "SubDemo")

_SCREEN.Menu.Tools.Add.AddObject("Report", "SubDemo")
_SCREEN.Menu.Tools.Add.AddObject("Remove", "SubDemo")

_SCREEN.Menu.Tools.Add.Report.AddObject("Print", "SubDemo")
_SCREEN.Menu.Tools.Add.Report.AddObject("Preview", "SubDemo")

*-- Demonstrate the problem.
WAIT WINDOW "Press any key to crash me (VFP 6 only)"
_SCREEN.Menu.Tools.Add.Remove.Execute()

*-- If you just DO KillItems here, without using the EXECUTE method
*-- then all is OK
*-- DO KillItems

*-- If all is well, we'll get to this point
_SCREEN.RemoveObject("Menu")
? "Done It"



*-- Remove a couple of the menu items
PROCEDURE KillItems
_SCREEN.Menu.Tools.Add.RemoveObject("Report")
_SCREEN.Menu.Tools.Add.RemoveObject("Remove")



*-- Define Two classes.
DEFINE CLASS MainDemo AS CUSTOM
Children = 0
ENDDEF

DEFINE CLASS SubDemo AS CUSTOM
PROTECTED pCommand
Children = 0
*-- For the demo, all objects have the same command
pCommand = "DO KillItems"

PROCEDURE Execute
LOCAL lcCommand
lcCommand = THIS.pCommand
*-- Start debugging here!
&lcCommand
ENDPROC

PROCEDURE Init
THIS.Parent.Children = THIS.Parent.Children + 1
? "INIT " + THIS.Name
ENDPROC

PROCEDURE Destroy
THIS.Parent.Children = THIS.Parent.Children - 1
? "KILL " + THIS.Name
ENDPROC

ENDDEF

*--------- End BugDemo.Prg
Regards
Mark

Microsoft VFP MCP
Menulib - OO Menus for VFP www.hidb.com/menulib
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform