From 9ca0d089a669f3f3e63f58f329d354055917700b Mon Sep 17 00:00:00 2001 From: Younguk Kim Date: Tue, 10 Apr 2018 19:45:54 +0900 Subject: [PATCH] event: fix a crash when removing a task is not owned by user --- panda/src/event/asyncTaskChain.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/panda/src/event/asyncTaskChain.cxx b/panda/src/event/asyncTaskChain.cxx index 47299d31ef..c7d732eca9 100644 --- a/panda/src/event/asyncTaskChain.cxx +++ b/panda/src/event/asyncTaskChain.cxx @@ -477,6 +477,7 @@ do_remove(AsyncTask *task, bool upon_death) { { int index = find_task_on_heap(_sleeping, task); nassertr(index != -1, false); + PT(AsyncTask) hold_task = task; _sleeping.erase(_sleeping.begin() + index); make_heap(_sleeping.begin(), _sleeping.end(), AsyncTaskSortWakeTime()); cleanup_task(task, upon_death, false); @@ -486,6 +487,7 @@ do_remove(AsyncTask *task, bool upon_death) { case AsyncTask::S_active: { // Active, but not being serviced, easy. + PT(AsyncTask) hold_task = task; int index = find_task_on_heap(_active, task); if (index != -1) { _active.erase(_active.begin() + index); @@ -769,7 +771,6 @@ cleanup_task(AsyncTask *task, bool upon_death, bool clean_exit) { } nassertv(task->_chain == this); - PT(AsyncTask) hold_task = task; task->_state = AsyncTask::S_inactive; task->_chain = nullptr;