Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
To release a form is NULL ok or need to Release()?
Message
 
 
À
11/03/2012 10:08:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01537966
Message ID:
01537973
Vues:
41
>>>>Hi,
>>>>
>>>>I have a procedure/function in my application that closes (I suppose) releases all open forms. The procedure sets the variable that references the open form to NULL. Now I got to think about if this is the right approach. Is it better to call the Release() method? Here is the segment of my code:
>>>>
>>>>
>>>>Function CloseForm
>>>>lparameter tcFormName
>>>>
>>>>*-- Find this form in the array of all currently open forms
>>>>FOR nRow = 1 to alen( aAppForms, 1 )  
>>>>
>>>>    *--- Found the element/row of the array matching search criteria!
>>>>    IF aAppForms[nRow,3] = tcFormName
>>>>        *-- Column 5 of the array stores the reference to the open form
>>>>        aAppForms[nRow,5] = NULL
>>>>       EXIT 
>>>>    ENDIF 
>>>>
>>>>NEXT 
>>>>
>>>>
>>>>Is it better to change the above aAppForms[nRow,5] = NULL with aAppForms[nRow,5].release()?
>>>
>>>
>>>Setting the refernce to null will not close the form ( if started with DO FORM ...)
>>>
>>>Best is to use
>>>
>>>= m. aAppForms[nRow,5].release()
>>>
>>>
>>>After that, provided the queryUnload() returns true, aAppForms[nRow,5] and all other places that hold a reference to that form, will be null
>>
>>I rarely if ever open forms with DO FORM... Most of the forms are in class libraries and are opened with either CREATEOBJ or NEWOBJECT But I will still change my code from NULL to .release()
>>
>>Thank you.
>
>
>See also Re: Cleaning up leftover objects Thread #1489909 Message #1489915 for further explanation

Thank you for the message that helps me understand this. Now I know why once in a while a customer would get an error that got me thinking of the way I was wrongly releasing the form (by setting to NULL). I should have changed this line to .release() long time ago.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform