Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it a bug for code-execution order?
Message
De
10/11/2007 07:12:01
 
 
À
07/11/2007 06:41:49
Lu Ping
Zhuhai Tec Co.
Zhuhai, Chine
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01267162
Message ID:
01268190
Vues:
15
Hi,

Bear in mind that you are releasing a reference to a form. This does not guarantee that the form itself is released at that time....

Regards,
Viv

> I agree to u.But I think it is a bug .It seems not reasonable that the destroy event of the current active window happen after the function (which call the form's releaes method).
> It is hard to program after the current form object released.Make programmer crazy.
> As if the destroy event push at the bottom of the stack when the form is current window ,
> but the destroy event never apppear in the stack window of debug tool.
>
>
>
>>I think the .Destroy() will occur in the Release order specified with the exception of the window that currently has focus. The .Destroy() for this will only occur after CloseMe() completes. Experiment with this:
>>SET PROCEDURE TO dx
>>ON KEY LABEL CTRL+A do closeme
>>
>>PUBLIC o1, o2 ,o3, o4
>>o1 = CREATEOBJECT([t1])
>>o1.Caption = "First"
>>o2 = CREATEOBJECT([t1])
>>o2.Caption = "Second"
>>o3 = CREATEOBJECT([t1])
>>o3.Caption = "Third"
>>o4 = CREATEOBJECT([t1])
>>o4.Caption = "Fourth"
>>IF MESSAGEBOX([show t1 form as top window?] ,4 ,[]) = 6		
>>	*- press ctrl+a ,then execute MESSAGEBOX([closeme]) first ,then execute MESSAGEBOX([destroy])
>>	o4.Show
>>	o3.show
>>	o2.Show
>>	o1.show
>>ELSE
>>	*- press ctrl+a ,then execute MESSAGEBOX([destroy]) first ,then execute MESSAGEBOX([closeme])
>>	o1.show
>>	o2.Show
>>	o3.show
>>	o4.Show
>>ENDIF
>>
>>DEFINE CLASS t1 as Form
>>	PROCEDURE destroy
>>		MESSAGEBOX([destroy]+THISFORM.Caption)
>>	ENDPROC
>>ENDDEFINE
>>
>>PROCEDURE closeme
>>	RELEASE o4
>>	RELEASE o3
>>	RELEASE o2
>>	RELEASE o1
>>	MESSAGEBOX([closeme])
>>	ON key
>>ENDPROC
>>
>>
>>
>>
>>
>>>Different code-execution order by whether t1 window is current active window.
>>>The test code below.
>>>Thanks for anyone's test.
>>>
>>>
>>>SET PROCEDURE TO xd
>>>ON KEY LABEL CTRL+A do closeme
>>>
>>>PUBLIC o1 ,o3
>>>o1 = CREATEOBJECT([t1])
>>>o3 = CREATEOBJECT([t2])
>>>IF MESSAGEBOX([show t1 form as top window?] ,4 ,[]) = 6		
>>>	*- press ctrl+a ,then execute MESSAGEBOX([closeme]) first ,then execute MESSAGEBOX([destroy])
>>>	o3.show
>>>	o1.show
>>>ELSE
>>>	*- press ctrl+a ,then execute MESSAGEBOX([destroy]) first ,then execute MESSAGEBOX([closeme])
>>>	o1.show
>>>	o3.show
>>>ENDIF
>>>DEFINE CLASS t1 as Form
>>>	PROCEDURE destroy
>>>		MESSAGEBOX([destroy])
>>>	ENDPROC
>>>ENDDEFINE
>>>
>>>DEFINE CLASS t2 as Form
>>>	ADD OBJECT c1 as commandbutton
>>>	PROCEDURE c1.click
>>>		=cl()
>>>	ENDPROC
>>>ENDDEFINE
>>>
>>>
>>>PROCEDURE closeme
>>>	RELEASE o1
>>>	RELEASE o3
>>>	MESSAGEBOX([closeme])
>>>	ON key
>>>ENDPROC
>>>
>>>PROCEDURE cl
>>>	=closeme()
>>>ENDPROC
>>>
>>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform