Merge pull request #255 from limbonaut/fix-setting-bt-crash

Fix: Keep `BTInstance` alive until update is finished (fixes #254)
This commit is contained in:
Serhii Snitsaruk 2024-12-04 18:15:55 +01:00 committed by GitHub
commit 9cfdabca3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 0 deletions

View File

@ -42,6 +42,7 @@ BT::Status BTInstance::update(double p_delta) {
double start = Time::get_singleton()->get_ticks_usec(); double start = Time::get_singleton()->get_ticks_usec();
#endif #endif
const Ref<BTInstance> keep_alive{ this }; // keep instance alive until update is finished
last_status = root_task->execute(p_delta); last_status = root_task->execute(p_delta);
emit_signal(LW_NAME(updated), last_status); emit_signal(LW_NAME(updated), last_status);