>PUBLIC oform1 > >oform1=NEWOBJECT("form1") >oform1.Show >RETURN > >DEFINE CLASS form1 AS form > > myobject = .NULL. > > ADD OBJECT command1 AS commandbutton WITH left = 150, Top = 50,AutoSize = .T. > > PROCEDURE myobject_assign > LPARAMETERS myObject > IF m.THIS.myObject=m.myObject >* this.myObject = m.myObject && you must exec this assign > RETURN > ENDIF > * here exists code that i want skip if m.THIS.myObject=m.myObject > THIS.myObject = m.myObject > ENDPROC > > > PROCEDURE command1.Click > THISFORM.MYobject= m.This > ENDPROC > >ENDDEFINE >>
>* form builded >* command1.RefCounter = 1 > >* User Click 1 >THISFORM.MYobject= m.This >* VFP compare m.THIS.myObject (NULL) with m.This, >* they are not equal VFP, continue >* call myobject_assign >... >THIS.myObject = m.myObject >* command1.RefCounter = 2 > >* User Click 2 >THISFORM.MYobject= m.This >* VFP compare m.THIS.myObject (Command1) with m.This, >* they are equal VFP, VFP sub 1 by command1.RefCounter && this is the bug cause >* command1.RefCounter = 1 >* call myobject_assign >... > >* User Click 3 >THISFORM.MYobject= m.This >* VFP compare m.THIS.myObject (Command1) with m.This, >* they are equal VFP, VFP sub 1 by command1.RefCounter >* command1.RefCounter = 0 ===> VFP release the CommandObject >* call myobject_assign >... >