Projects > cpp > Issues > Bug #3457

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

Infinite loop in UserDefault's destructor on iOS.

Bug #3457 [Closed]
dumganhar 2013-12-20 06:03 . Updated almost 3 years ago

Reproduce Step:
Invoking UserDefault::destroyInstance() on iOS.
Solution:
To prevent developer uses delete UserDefault::getInstance(), we need to make the destructor of UserDefault as private function.
Therefore, developer could only use getInstance and destroyInstance. And delete UserDefault::getInstance() will be forbidden.

UserDefault* UserDefault::getInstance()
{
    ...
    if (! _userDefault)
    {
        _userDefault = new UserDefault();
    }

    return _userDefault;
}

void UserDefault::destroyInstance()
{
    CC_SAFE_DELETE(_userDefault);
}
dumganhar 2013-12-20 12:31
  • Status changed from New to Closed
  • % Done changed from 0 to 100

Applied in changeset commit:f086c2b63a4b7a208a4a74c6ae64b5d9a62e6a9e.

Atom PDF

Status:Closed
Start date:2013-12-20
Priority:Normal
Due date:
Assignee:dumganhar
% Done:

100%

Category:all
Target version:3.0-beta

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.