summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-10-22 14:17:58 +0200
committerGitHub <noreply@github.com>2019-10-22 14:17:58 +0200
commit2906cef290c8af61f84e26c889963d355f9e9834 (patch)
tree2f0652e599876718641f46dd5b3466ee6543a964
parent8228b93fcd2a4c47d6e10aca0a96a90f4835a096 (diff)
parent1a9801f7007ceb5dc894a0da1d90d1f8201b44fc (diff)
downloadredot-engine-2906cef290c8af61f84e26c889963d355f9e9834.tar.gz
Merge pull request #32922 from nekomatata/fix-scene-timer-yield-leak
Fixed leak on exit when using yield with SceneTreeTimer
-rw-r--r--scene/main/scene_tree.cpp17
-rw-r--r--scene/main/scene_tree.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 830d314245..38ad6886b1 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -78,6 +78,17 @@ bool SceneTreeTimer::is_pause_mode_process() {
return process_pause;
}
+void SceneTreeTimer::release_connections() {
+
+ List<Connection> connections;
+ get_all_signal_connections(&connections);
+
+ for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
+ Connection const &connection = E->get();
+ disconnect(connection.signal, connection.target, connection.method);
+ }
+}
+
SceneTreeTimer::SceneTreeTimer() {
time_left = 0;
process_pause = true;
@@ -611,6 +622,12 @@ void SceneTree::finish() {
memdelete(root); //delete root
root = NULL;
}
+
+ // cleanup timers
+ for (List<Ref<SceneTreeTimer> >::Element *E = timers.front(); E; E = E->next()) {
+ E->get()->release_connections();
+ }
+ timers.clear();
}
void SceneTree::quit() {
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index d387886d61..ef847ebb5b 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -61,6 +61,8 @@ public:
void set_pause_mode_process(bool p_pause_mode_process);
bool is_pause_mode_process();
+ void release_connections();
+
SceneTreeTimer();
};