From bea5d1c27dc6d1489bdf77bd1a7251e0a7a7e8ca Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Wed, 1 Jun 2022 17:03:42 +0700 Subject: [PATCH] Check if baton FuncRef is valid before calling call_funcv() Often when closing a terminal in the terminal panel the error message 'Condition "!obj" is true.' would be printed to console. This was due to the call_funcv() method being called on an invalid FuncRef instance (invalid because it had already been deleted or queued for delection). Now we check the instance is valid before calling the method. --- CHANGELOG.md | 3 ++- addons/godot_xterm/native/src/node_pty/unix/pty.cc | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f934a4b..e4d1c0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - The `kill()` method of unix PTY node can now be called without error as the underlying `pipe.close()` method of the gdnative library is now registered. - +- Fixed 'Condition "!obj" is true.' error that would often print to console when + closing terminals in the Terminal panel of the editor plugin. ## [v2.0.0](https://github.com/lihop/godot-xterm/compare/v1.2.1...v2.0.0) - 2021-07-25 diff --git a/addons/godot_xterm/native/src/node_pty/unix/pty.cc b/addons/godot_xterm/native/src/node_pty/unix/pty.cc index 560c78b..dd1b64c 100644 --- a/addons/godot_xterm/native/src/node_pty/unix/pty.cc +++ b/addons/godot_xterm/native/src/node_pty/unix/pty.cc @@ -445,8 +445,8 @@ static void pty_after_waitpid(uv_async_t *async) { Array argv = Array::make(baton->exit_code, baton->signal_code); - ERR_FAIL_COND(baton->cb == nullptr); - baton->cb->call_funcv(argv); + if (baton->cb != nullptr && baton->cb->is_valid()) + baton->cb->call_funcv(argv); uv_close((uv_handle_t *)async, pty_after_close); }