瀏覽代碼

Do not start `Timer` upon manual switching of internal process

Prevents `Timer` to prematurely start and timeout immediately if internal
processing is enabled manually with `Timer.set_process_internal(true)` or
`Timer.set_physics_process_internal(true)`.

Even if the internal processing is enabled manually, the user still has to
actually start the timer with `start()` method explicitly.

(cherry picked from commit afcb6f38db9c313328130b6632073cda7f3b98e0)
Andrii Doroshenko (Xrayez) 5 年之前
父節點
當前提交
e95e934d88
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      scene/main/timer.cpp

+ 4 - 2
scene/main/timer.cpp

@@ -48,8 +48,9 @@ void Timer::_notification(int p_what) {
 			}
 			}
 		} break;
 		} break;
 		case NOTIFICATION_INTERNAL_PROCESS: {
 		case NOTIFICATION_INTERNAL_PROCESS: {
-			if (timer_process_mode == TIMER_PROCESS_PHYSICS || !is_processing_internal())
+			if (!processing || timer_process_mode == TIMER_PROCESS_PHYSICS || !is_processing_internal()) {
 				return;
 				return;
+			}
 			time_left -= get_process_delta_time();
 			time_left -= get_process_delta_time();
 
 
 			if (time_left < 0) {
 			if (time_left < 0) {
@@ -63,8 +64,9 @@ void Timer::_notification(int p_what) {
 
 
 		} break;
 		} break;
 		case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
 		case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
-			if (timer_process_mode == TIMER_PROCESS_IDLE || !is_physics_processing_internal())
+			if (!processing || timer_process_mode == TIMER_PROCESS_IDLE || !is_physics_processing_internal()) {
 				return;
 				return;
+			}
 			time_left -= get_physics_process_delta_time();
 			time_left -= get_physics_process_delta_time();
 
 
 			if (time_left < 0) {
 			if (time_left < 0) {