Skip to content

[cocos2d-x C++] UIButton::setTitleLabel Memory Leak #18677

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

Closed
XTC-3 opened this issue Feb 3, 2018 · 0 comments
Closed

[cocos2d-x C++] UIButton::setTitleLabel Memory Leak #18677

XTC-3 opened this issue Feb 3, 2018 · 0 comments

Comments

@XTC-3
Copy link

XTC-3 commented Feb 3, 2018

  • cocos2d-x version: 3.17
  • devices test on: simulator
  • developing environments
    • NDK version:
    • Xcode version: 9.2
    • VS version:
    • browser type and version:

Steps to Reproduce:

UIButton appears to be leaking memory for me. More specifically _titleRenderer’s retain in Button::setTitleLabel() doesn’t have a matching release.

Removing the retain from Button::setTitleLabel() fixes the leak.

Is there a reason retain is being called on _titleRenderer even though it’s being added as a child?

void Button::setTitleLabel(Label* label)
{
    if (_titleRenderer != label) {
        CC_SAFE_RELEASE(_titleRenderer);
        _titleRenderer = label;
        CC_SAFE_RETAIN(_titleRenderer);

        addProtectedChild(_titleRenderer, TITLE_RENDERER_Z, -1);
        updateTitleLocation();
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants