Hi Ron, I'm fine here, but recovering from a broken elbow that required
surgery.
Destructor of TMyClass( 1 ) is executed, destructor of TMyClass( 3 ) is
executed, but destructor of TMyClass( 2 ) is not executed.
See trace.log
----------------------------------------------------------------------------------------------------------------------------------
[destruct2.prg->TMYCLASS2:CLEANUP] (63) Called from:
destruct2.prg->TMYCLASS2:__DESTRUCTOR(37)
destruct2.prg->MAIN(17)
Type: N >>> 8<<<
Type: N >>> 3<<<
[destruct2.prg->TMYCLASS:CLEANUP] (44) Called from:
destruct2.prg->TMYCLASS:__DESTRUCTOR(37)
destruct2.prg->TMYCLASS2:CLEANUP(65)
destruct2.prg->TMYCLASS2:__DESTRUCTOR(37)
destruct2.prg->MAIN(17)
Type: N >>> 3<<<
[destruct2.prg->TMYCLASS:CLEANUP] (42) Called from:
destruct2.prg->TMYCLASS2:CLEANUP(66)
destruct2.prg->TMYCLASS2:__DESTRUCTOR(37)
destruct2.prg->MAIN(17)
Type: N >>> 8<<<
Type: N >>> 2<<<
---- Here should be show the destruction of tmyclass( 2 ) in oVar1:oVar2
trace expected ...
[destruct2.prg->TMYCLASS:CLEANUP] (44) Called from:
destruct2.prg->TMYCLASS:__DESTRUCTOR(37)
destruct2.prg->TMYCLASS2:CLEANUP(66)
destruct2.prg->TMYCLASS2:__DESTRUCTOR(37)
destruct2.prg->MAIN(17)
Type: N >>> 2<<<
------------------------------------------------------------------------------------------------------
[destruct2.prg->MAIN] (19)
Type: C >>>end<<<
> Why destructor for TMyClass(2)? On quick read it seems that value of
> oVar1:oVar2 is being set, while the pre-existing value of oVar1 is
> TMyClass2(8), which its :oVar2 data is not initialized with any value,
> so no destructor should be called,. What am I missing?
See the same code but initializing oVar and oVar1 in body of program for
more readibility.
PROCEDURE MAIN()
LOCAL oVar, oVar1
oVar := TMyClass(7)
oVar:oVar2 := TMyClass( 1 )
oVar1 := TMyClass2( 8 )
oVar1:oVar2 := TMyClass( 2 )
oVar1:oVar3 := TMyClass( 3 )
tracelog("cleaning return area")
oVar := nil
oVar1 := nil
tracelog("end")
RETURN
*Walter Negro*
/Desarrollo e Investigación/
VsTour - Softmagic S.R.L.
( 54 ) ( 11 ) 5218-6616
Av. Corrientes 2294 Piso 7 Of.33
C1046AAN - Buenos Aires - Argentina
[email protected] <mailto:[email protected]>
------------------------------------------------------------------------
*::* *VSTour.COM <http://www.vstour.com> * *::*
El 27/07/2012 06:45 p.m., Ron Pinkas escribió:
> Hey Walter, how are you? :-)
>
>> oVar:oVar2 := TMyClass( 1 )
>>
>> oVar1:oVar2 := TMyClass( 2 ) // destructor of TMyClass( 2 ) is not
>> executed
>
> Why destructor for TMyClass(2)? On quick read it seems that value of
> oVar1:oVar2 is being set, while the pre-existing value of oVar1 is
> TMyClass2(8), which its :oVar2 data is not initialized with any value,
> so no destructor should be called,. What am I missing?
>
> Ron
>
> --------------------------------------------------
> From: "Walter Negro" <[email protected]>
> Sent: Thursday, July 26, 2012 7:40 AM
> To: "xHarbour" <[email protected]>
> Subject: [xHarbour-developers] Problem with destructor called from
> supermethods
>
>> Ron:
>>
>> I found a problem when destructor should be executed from method of
>> super class.
>> This entry in ChangeLog.020 is when actual code was added.
>>
>> 2004-05-10 01:52 UTC-0800 Ron Pinkas <[email protected]>
>> * source/vm/classes.c
>> + Added logic to disallow Destructor calls on faked super objects,
>> as well as temp super objects created with __clsInstSuper()
>>
>>
>> The code that causes the problem in hb_clsFinalize() function is:
>>
>> if( HB_IS_SYMBOL( hb_stackBaseItem() ) &&
>> hb_stackBaseItem()->item.asSymbol.pCargo->uiSuperClass == 0 && strcmp(
>> hb_stackBaseItem()->item.asSymbol.value->szName, "__CLSINSTSUPER" ) )
>>
>>
>> The next code demonstrates the problem:
>> destructor of TMyClass( 2 ) is not executed
>>
>> destruc2.prg
>> //------------------------------------------------------------------------------------------
>>
>>
>> #include "hbclass.ch"
>>
>> PROCEDURE MAIN()
>>
>> LOCAL oVar := TMyClass(7), oVar1 := TMyClass2( 8 )
>>
>> oVar:oVar2 := TMyClass( 1 )
>>
>> oVar1:oVar2 := TMyClass( 2 ) // destructor of TMyClass( 2 ) is not
>> executed
>> oVar1:oVar3 := TMyClass( 3 )
>>
>> // cleaning return area because contain the TMyClass( 3 ) object and
>> // destructors preserve the return area when that are executed
>> tracelog("cleaning return area")
>>
>> oVar := nil
>> oVar1 := nil
>>
>> tracelog("end")
>> RETURN
>>
>> CLASS TMyClass
>>
>> DATA nVar
>>
>> DATA oVar2
>>
>> METHOD NEW( nVar ) CONSTRUCTOR
>>
>> METHOD Cleanup()
>>
>> DESTRUCTOR MyDestructor
>>
>> ENDCLASS
>>
>> PROCEDURE MyDestructor CLASS TMyClass
>> ::CleanUp()
>> RETURN
>>
>> METHOD CleanUp() CLASS TMyClass
>> if ::oVar2 != nil
>> TraceLog(::nVar,::oVar2:nVar)
>> else
>> TraceLog(::nVar)
>> endif
>> ::oVar2 := nil
>> ? "Cleanup:", ::nVar
>> RETURN nil
>>
>> METHOD New( nVar ) CLASS TMyClass
>>
>> ::nVar := nVar
>>
>> RETURN Self
>>
>> CLASS TMyClass2 From TMyClass
>> DATA oVar3
>> METHOD CleanUp()
>> ENDCLASS
>>
>> METHOD Cleanup()CLASS TMyClass2
>> if ::oVar3 != nil
>> TraceLog(::nVar,::oVar3:nVar)
>> endif
>> ::oVar3 := nil
>> super:cleanup()
>> RETURN NIL
>>
>>
>>
>> ------------------------------------------------------------------------------
>>
>>
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond.
>> Discussions
>> will include endpoint security, mobile security and the latest in
>> malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> xHarbour-developers mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/xharbour-developers
>>
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
xHarbour-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xharbour-developers