You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
845 B
48 lines
845 B
# This implements a "fake timer" object that emits the "timeout" signal
|
|
# and a target object slot connected to this signal.
|
|
|
|
# We also test the immediate object deletion...it seems to work
|
|
|
|
class(faketimer,object)
|
|
{
|
|
timerEvent(<timer id>)
|
|
{
|
|
$this->$emit(timeout,$0)
|
|
}
|
|
}
|
|
|
|
|
|
class(target,object)
|
|
{
|
|
constructor
|
|
{
|
|
$$->%num = 10;
|
|
}
|
|
|
|
timerSlot(<timer id>)
|
|
{
|
|
echo "Timer $0 fired $$->%num"
|
|
$$->%num--;
|
|
if($$->%num == 0)
|
|
{
|
|
echo "Deleting sender $$->$signalSender()->$name() : Kaboom!"
|
|
# Immediate sender deletion....
|
|
delete -i $$->$signalSender
|
|
$$->$startTimer(1000)
|
|
}
|
|
}
|
|
|
|
timerEvent(<timer id>)
|
|
{
|
|
echo "Deleting self! : Kaboom!"
|
|
delete $this;
|
|
}
|
|
}
|
|
|
|
|
|
%source = $new(faketimer,0,sender)
|
|
%target = $new(target,0,target)
|
|
connect %source timeout %target timerSlot
|
|
echo "Starting timer...."
|
|
%source->$startTimer(1000)
|