Merge pull request #32922 from nekomatata/fix-scene-timer-yield-leak

Fixed leak on exit when using yield with SceneTreeTimer
This commit is contained in:
Rémi Verschelde 2019-10-22 14:17:58 +02:00 committed by GitHub
commit 2906cef290
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -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() {

View file

@ -61,6 +61,8 @@ public:
void set_pause_mode_process(bool p_pause_mode_process);
bool is_pause_mode_process();
void release_connections();
SceneTreeTimer();
};