Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Possible WISH LIST item?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00149579
Message ID:
00150229
Vues:
27
Hey Christof,

>
>Yep, at least for VFP objects in a usual VFP environment. I haven't tried this neither with OLE server nor with ActiveX controls.

You can't release COM components from within themselves. Only
an external reference can reduce the reference count and the object
goes away only and only if the reference count goes to 0 (or
you terminate the process). Even QUIT and CANCEL won't do it,
which is a good thing! If you did what is the client supposed
to do when the reference goes away other than fail or abort
with an error.


ActiveX controls are controls - you can always make the container
release them, but if they have references to other object (like
NODES etc) that are outstanding the object may not release properly
either. You may end up with a memory leak for left over references.
This usually points at badly designed controls that don't handle
cleanup properly.

>Well, RELEASE THIS is part of the Release() method, no Destroy. It will fire Destroy() just after finishing Release(). In the Destroy() event of containers I use RemoveObject() to release all contained object prior to finally destroying the object. At that point it's the only object and no other object is pointing to it.

No but the destroy *will* fire possibly in many subclasses in the hierarchy
after you do a RELEASE THIS. Also, if you want you can put code after
RELEASE THIS and it will work, but what's your state at that point?
Ok, that's bad code and you probably won't do that, but still it's
a questionable situation.


>
>>If you want a good idea try it in C++ by calling the destructor directly
>>from within a class method <s>...
>
>That's a different thing, don't you think?

Not really - it demonstrates the WHY of internal release...

The only reason you should ever have to do a RELEASE THIS is because
there's a problem with VFP not doing its job cleaning up references
when it should.

I think we're talking about two different things. You're talking about
cleanup for the sake of releasing objects cleanly. I'm talking about
the architectual issue of having servers terminate themselves which
simply doesn't make sense. Whether RELEASE THIS works or not is
rather irrelevant in this scenario, because as I described above the
client will be corrupted. This may make sense for forms tied to a
READ EVENTS loop where everything falls out after you CLEAR EVENTS
but doesn't once you have to actually manage the object state
manually by releasing references or falling out of scope.

+++ Rick ---
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform