From 2ce5680a6a6690031ce829d09f159b81f16255d6 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Mon, 10 Apr 2023 12:59:23 +0300 Subject: [PATCH] fix weakref on CCTextInputNode --- loader/src/utils/cocos.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/loader/src/utils/cocos.cpp b/loader/src/utils/cocos.cpp index d6e4c011..1aa0cb8b 100644 --- a/loader/src/utils/cocos.cpp +++ b/loader/src/utils/cocos.cpp @@ -257,6 +257,10 @@ void WeakRefPool::check(CCObject* obj) { // if this object's only reference is the WeakRefPool aka only weak // references exist to it, then release it if (obj && m_pool.contains(obj) && obj->retainCount() == 1) { + // set delegates to null because those aren't retained! + if (auto input = typeinfo_cast(obj)) { + input->m_delegate = nullptr; + } obj->release(); // log::info("nullify {}", m_pool.at(obj).get()); m_pool.at(obj)->m_obj = nullptr;