|
楼主 |
发表于 2008-8-30 12:22:02
|
显示全部楼层
为什么DestroyCondition这样用不对呢
可以测试下这段代码
[jass]
function Test_Condition_A takes nothing returns boolean
return false
endfunction
function Test_Condition_B takes nothing returns boolean
return false
endfunction
function Test_Action_01 takes nothing returns nothing
local conditionfunc A = Condition(function Test_Condition_A)
local conditionfunc B = Condition(function Test_Condition_B)
call BJDebugMsg(H2S(A))
call BJDebugMsg(H2S(B))
call BJDebugMsg("----------")
set A = null
set B = null
endfunction
function Test_Action_02 takes nothing returns nothing
local conditionfunc A = Condition(function Test_Condition_A)
local conditionfunc B = Condition(function Test_Condition_B)
call BJDebugMsg(H2S(A))
call BJDebugMsg(H2S(B))
call BJDebugMsg("----------")
call DestroyCondition(A)
call DestroyCondition(B)
set A = null
set B = null
endfunction
function Test_Action_03 takes nothing returns nothing
local conditionfunc A = Condition(function Test_Condition_A)
local conditionfunc B = Condition(function Test_Condition_B)
call BJDebugMsg(H2S(A))
call BJDebugMsg(H2S(B))
call BJDebugMsg("----------")
call DestroyBoolExpr(A)
call DestroyBoolExpr(B)
set A = null
set B = null
endfunction
//===========================================================================
function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "1", true )
call TriggerAddAction( t, function Test_Action_01 )
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "2", true )
call TriggerAddAction( t, function Test_Action_02 )
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent( t, Player(0), "3", true )
call TriggerAddAction( t, function Test_Action_03 )
endfunction
[/jass]
如果用了Condition,而什么都不干,下次再使用,不会重复创造新的值
如用了DestroyCondition,直接泄露了..........
如用了DestroyBoolExpr ,handle了正常删除 |
|