Skip to content

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

@XTC-3

Description

@XTC-3
  • 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();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions