Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG: skip the Assign destroy object or fire a C5 crash
Message
 
À
15/04/2004 14:38:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00893546
Message ID:
00895605
Vues:
34
>
>Simply because of proper encapsulation, if you don't want to create an object, you shouldn't let factors outside of that object make the determination.
>

>
>I'd think you'd want outside factors have an opportunity to do anything they want, even try to make the assignment, but have control within your object allow it or not. (Which is what I think you are saying.) Thus making the bug that I introduced a dangerous one. When you have a property that has an assign method and you don't assign the lparameter to the property it will cause memory to be corrupt and will eventually cause a C5 error.

Bob,

I don't believe that the problem is skipping the assignment, but rather having an object with an _assign event. I created the following test to determine if the act of skipping the assignment would cause a C5. The test was run six times (in the context of the program this equates to 6,000,000) without generating a C5
DEFINE CLASS TestAssign AS Custom 
   somevalue = 0
   
   FUNCTION Init
     This.somevalue = -1
   ENDFUNC 
   
   PROCEDURE RunTest
   
   LOCAL lni
   FOR lni = 1 TO 1000000
     This.somevalue = lni
   NEXT 
   ENDPROC 
   
   PROCEDURE somevalue_assign
     
     LPARAMETERS vNewVal
     
     IF m.vNewVal < This.somevalue THEN 
       This.somevalue = m.vNewVal
     ENDIF 
   ENDPROC 
ENDDEFINE
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform