Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Observer Pattern: Dangling References
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00354611
Message ID:
00356072
Views:
15
Ken,

I just created a listbox subclass, gave it an Attach() method, an aObservers and nObservers property. Attach increments nObservers, dimensions the array and assigns the reference parameter to the array location. In the InteractiveChange() it loops through the array and calls the Move(1,1) method of all the observers. In Destroy() I just this.aObservers = .null. I dropped the listbox on a form and a textbox and command button on the form. In the form.Init() I attached the two controls to the listbox, and in their Move() I nodefaulted and moved the control 1 pixel down and 1 pixel right. When the form ran the observers moved and closing the form everything went away ok. I then added another listbox subclass to the form and Attached the two controls to it also. The controls moved as selection changed in both listboxes. The form also closed fine even with the zorder of the two observer controls were in between the two listboxes.

Can you try simplifying things down to just your subject and observers and see if that works? Have you tried event logging to track the issue?

>>The destruct order shouldn't matter.
>
>Isn't the destruct order what's causing the dangling references?
>
>>Do your observers also hold a reference to the subject?
>
>The only object references are in the subject object.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform