Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dangling reference?
Message
From
31/07/2010 01:57:13
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Dangling reference?
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01474712
Message ID:
01474712
Views:
282
Hi Experts,

I made a container class cntImages that contains five image controls plus some other controls. I also added a property called oImages in cntImages.

In the INIT event of the cntImages, I have the following:
This.oImages = CREATEOBJECT( "Collection" )

This.oImages.Add( This.img01, "image1" )
This.oImages.Add( This.img02, "image2" )
This.oImages.Add( This.img03, "image3" )
This.oImages.Add( This.img04, "image4" )
This.oImages.Add( This.img05, "image5" )
The image controls are based on my base image class. So is the container (based on my base container class).

I did this so I can just do a FOR EACH loop to do stuff on those image controls.

To test, I created it and place it on a form. Works fine. I then closed the form.

The problem lies when I try to modify the form again. I get a "FILE IS IN USE" error!

Also, if I try to go back to open the cntImage class, I then get a "Remove classes from memory?" message. Only upon clicking Remove will I be able to access both the class and the form concerned.

I believe this has something to do with dangling references, but I tried this code in the Destroy event of the container:
LOCAL i

FOR i = 1 TO This.oImages.Count
   RELEASE This.oImages.Item( i )
ENDFOR

DO WHILE This.oImages.Count # 0
   This.oImages.Remove( 1 )
ENDDO

This.oImages = NULL
also, this other way:
FOR EACH loImage IN This.oImages
   RELEASE loImage
ENDFOR
All for naught... help!

Dennis
Next
Reply
Map
View

Click here to load this message in the networking platform