Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于Slot::__disposeDisplay的函数参数isRelease的疑问 #183

Open
scutXu opened this issue Apr 18, 2018 · 1 comment
Open

关于Slot::__disposeDisplay的函数参数isRelease的疑问 #183

scutXu opened this issue Apr 18, 2018 · 1 comment

Comments

@scutXu
Copy link

scutXu commented Apr 18, 2018

//Slot::_onClear中的一段代码

std::vector<std::pair<void*, DisplayType>> disposeDisplayList;
for (const auto& pair : this->_displayList)
{
    if (
        pair.first != nullptr && pair.first != _rawDisplay && pair.first != _meshDisplay &&
        std::find(disposeDisplayList.cbegin(), disposeDisplayList.cend(), pair) == disposeDisplayList.cend()
    )
    {
        disposeDisplayList.push_back(pair);
    }
}

for (const auto& pair : disposeDisplayList)
{
    if (pair.second == DisplayType::Armature)
    {
        static_cast<Armature*>(pair.first)->returnToPool();
    }
    else
    {
        _disposeDisplay(pair.first, true);
    }
}

if (_meshDisplay && _meshDisplay != _rawDisplay) 
{
    _disposeDisplay(_meshDisplay, false);
}

if (_rawDisplay) {
    _disposeDisplay(_rawDisplay, false);
}

代码相比于5.0版本增加了这个参数,但是这个参数是否还未起作用呢?我看CCSlot中的方法实现并没有根据这个参数进行一些逻辑判断。如果我没猜错的话,这个修改的本意是将上面代码中pair.first != _rawDisplay && pair.first != _meshDisplay 去掉,并且CCSlot中根据isRelease去判断是否释放该display对象

@akdcl
Copy link
Member

akdcl commented Apr 18, 2018

你好,该参数是全平台都带着的参数,目的是区分是要最终释放,还是持有减一,通常引擎都没有持有减一的功能(除了 cocos2dx),只有最终释放,所以这个参数对 cocos2dx 没用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants