The example below shows that__Delete is also not called if the object contains a bound method:__Delete is not called for any object which has the key "__Class". Class objects have this key by default.
Code: Select all
counter := new SecondCounter
Msgbox, % counter.HasKey("__Class") "`n" SecondCounter.HasKey("__Class")
counter.Start()
Sleep 5000
counter.Stop()
Sleep 2000
counter = ; I would expect a ToolTip to show up as a result of this operation
Sleep 2000
Return
; From https://autohotkey.com/docs/commands/SetTimer.htm#ExampleClass
class SecondCounter {
__New() {
this.interval := 1000
this.count := 0
this.timer := ObjBindMethod(this, "Tick") ; of this.Tick.Bind(this)
}
Start() {
timer := this.timer
SetTimer % timer, % this.interval
ToolTip % "Counter started"
}
Stop() {
timer := this.timer
SetTimer % timer, Off
ToolTip % "Counter stopped at " this.count
}
Tick() {
ToolTip % ++this.count
}
; This function is the only addition to the example
__Delete() {
ToolTip Deleting object ...
}
}
Cheers!__Delete is not called for any object which has the key "__Class" or contains a bound method. Class objects have this key by default.