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.
This commit is contained in:
Leroy Hopson 2022-06-01 17:03:42 +07:00
parent d124f20f36
commit bea5d1c27d
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
2 changed files with 4 additions and 3 deletions

View file

@ -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);
}