| 1639 | } |
| 1640 | |
| 1641 | void GDScript::cancel_pending_functions(bool warn) { |
| 1642 | MutexLock lock(GDScriptLanguage::get_singleton()->mutex); |
| 1643 | |
| 1644 | while (SelfList<GDScriptFunctionState> *E = pending_func_states.first()) { |
| 1645 | // Order matters since clearing the stack may already cause |
| 1646 | // the GDScriptFunctionState to be destroyed and thus removed from the list. |
| 1647 | pending_func_states.remove(E); |
| 1648 | GDScriptFunctionState *state = E->self(); |
| 1649 | #ifdef DEBUG_ENABLED |
| 1650 | if (warn) { |
| 1651 | WARN_PRINT("Canceling suspended execution of \"" + state->get_readable_function() + "\" due to a script reload."); |
| 1652 | } |
| 1653 | #endif |
| 1654 | ObjectID state_id = state->get_instance_id(); |
| 1655 | state->_clear_connections(); |
| 1656 | if (ObjectDB::get_instance(state_id)) { |
| 1657 | state->_clear_stack(); |
| 1658 | } |
| 1659 | } |
| 1660 | } |
| 1661 | |
| 1662 | GDScript::~GDScript() { |
| 1663 | if (destructing) { |
no test coverage detected