From c8d1e88a9715e49f5bc137057e9429789ee9c747 Mon Sep 17 00:00:00 2001 From: Cvolton Date: Mon, 25 Mar 2024 23:24:20 +0100 Subject: [PATCH] fix memory leak in handletouchpriority --- loader/src/utils/cocos.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/loader/src/utils/cocos.cpp b/loader/src/utils/cocos.cpp index 938c4411..bb4e9abe 100644 --- a/loader/src/utils/cocos.cpp +++ b/loader/src/utils/cocos.cpp @@ -500,15 +500,13 @@ void GEODE_DLL geode::cocos::handleTouchPriorityWith(cocos2d::CCNode* node, int } } void GEODE_DLL geode::cocos::handleTouchPriority(cocos2d::CCNode* node, bool force) { - node->retain(); - Loader::get()->queueInMainThread([node, force]() { - if (auto delegate = typeinfo_cast(node)) { + Loader::get()->queueInMainThread([node = Ref(node), force]() { + if (auto delegate = typeinfo_cast(*node)) { if (auto handler = CCTouchDispatcher::get()->findHandler(delegate)) { return handleTouchPriorityWith(node, handler->m_nPriority - 1, force); } } handleTouchPriorityWith(node, 0, force); - node->release(); }); }