메뉴 건너뛰기

창작에 관련된 질문이나 간단한 팁, 예제를 올리는 곳

만약 CocoStudio로 UI를 만든 후
GUIReader를 써서 지정 폰트를 불러오면
엔진 버그로 인해서 메모리 누수가 생긴다.
이걸 고치려면 LabelBMFont.cpp를 아래와 같이 수정해야 한다.

void LabelBMFont::setFntFile(const char *fileName)
{
    if (!fileName || strcmp(fileName, "") == 0)
    {
        return;
    }

    _fntFileName = fileName;
    _labelBMFontRenderer->initWithString("", fileName);
    _labelBMFontRenderer->setFntFile(fileName);
    updateAnchorPoint();
    labelBMFontScaleChangedWithSize();
    _fntFileHasInit = true;
    setText(_stringValue.c_str());
}

initWithString을 지우고
SetFntFile을 집어넣는다.

원래대로라면 Init를 두번하는 셈이 되므로
이 경우 TextAtlas가 중복 생성되서 메모리 누수가 발생한다.

일단 cocos2d-x의 CCLabelBMFont는 두번 init를 허용하지 않는데
왜 이렇게 두번 init하게 프로그램을 짜놨는지 모르겠다.
실수겠지...
조회 수 :
783
등록일 :
2014.03.10
02:21:11 (*.75.34.131)
엮인글 :
게시글 주소 :
https://hondoom.com/zbxe/index.php?mid=study&document_srl=769819

clans

2014.05.24
11:26:02
(*.197.153.233)

좋은정보 퍼가요 제블로그에 출처 남겨둘게요.^^

sunghoon

2014.05.31
19:30:24
(*.177.106.187)

좋은 정보 감사합니다. 퍼갈게요

List of Articles