-
-
Notifications
You must be signed in to change notification settings - Fork 23.1k
Closed
Description
Greetings,
The timer emits the timeout signal when stop() is called. The following code demonstrates the behaviour:
func timeout1():
print("timeout1 -- stopping timer 2")
get_node("timer-2").stop()
func timeout2():
print("Should never be displayed")
func _ready():
var timer1 = get_node("timer-1")
timer1.set_wait_time(1)
timer1.connect("timeout", self, "timeout1")
timer1.set_one_shot(true)
timer1.start()
var timer2 = get_node("timer-2")
timer2.set_wait_time(2)
timer2.connect("timeout", self, "timeout2")
timer2.start()
I temporarily fixed the issue by modifying scene/main/timer.cpp as follows:
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index f718a09..6f7fec6 100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -46,15 +46,17 @@ void Timer::_notification(int p_what) {
} break;
case NOTIFICATION_PROCESS: {
- time_left -= get_process_delta_time();
+ if (time_left != -1) {
+ time_left -= get_process_delta_time();
- if (time_left<0) {
- if (!one_shot)
- time_left=wait_time+time_left;
- else
- stop();
+ if (time_left<0) {
+ if (!one_shot)
+ time_left=wait_time+time_left;
+ else
+ stop();
- emit_signal("timeout");
+ emit_signal("timeout");
+ }
}
} break;
Metadata
Metadata
Assignees
Labels
No labels