Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Destroy events out of order?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
01170979
Message ID:
01171065
Vues:
8
Mark,

An object can not destruct while one of its or one of its contained objects methods is on the call stack. You should get out of the habit of doing things like calling the Click() method of an internal object. You should instead call a form level method from both the cmdCancel.Click() and from the outside object. If you are holding object references like this you should always check to make sure it's still a valid reference before attempting to use it.

You might consider using a Register()/Unregister() method so that the two forms can tell each other that they are shutting down.

>I'm stumped. Why is this happening?
>- Click() method of cancel button on modeless form A is invoked.
>- Form A's cancel routine checks for existence of a modeless child form B that form A might have created earlier. If B exists, then A invokes the Click() method for B's cancel button, and B releases itself. Also, if B exists, it holds an object reference back to form A (as a form property initialized in B's INIT)
>- B's cancel routine returns as expected to A's calling code. Then A releases itself. B has already released itself. In B's destroy event, it tries to access the object reference to A.
>
>Result: Error. The reference to Form A is no longer valid. Form A's destroy event has fired before B's. This seems odd to me. Along the timeline, the "inner" cancel operation is that of form B, yet the first destroy event to occur is that of form A.
>
>Keep in mind I'm talking about separate and equal modeless forms. There is no containerization here as with controls on a form.
>
>I would instead expect the following:
>- Form A calls B's cancel method
>- Form B releases itself in this method and B's DESTROY is called
>- Form B's DESTROY completes and since form A is still around, the object reference to A is still valid.
>- Form A releases itself
>- Form A's DESTROY occurs
>
>But I have proven (to myself anyway) that such is not the case. DESTROY events for a collection of modeless forms do not seem serialized to the order of execution of the corresponding RELEASE method within each form.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform