Projects > cpp > Issues > Bug #3897

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

Create Issue on Github

Constructors should be protected, but should be a way to disable them

Bug #3897 [Closed]
ricardo 2014-02-05 23:03 . Updated over 9 years ago

For more info:
http://www.cocos2d-x.org/forums/6/topics/34011?r=44278#message-44278

Basically, we moved many constructors to protected. That is good, since it will prevent many memory leaks.

But advanced users my still want to create objects manually, or even create objects in the "stack".

And we should support those use cases.

So, a user suggested to do the following:

1
2
3
4
5
#ifdef CC_ENABLE_CONSTRUCTORS
#define PROTECTED_CONSTRUCTOR protected
#else
#define PROTECTED_CONSTRUCTOR public
#endif

I think it adds little overhead, and advanced users will be happy with this compile-time feature.

ricardo 2014-02-05 23:04
  • Description updated (diff)
ricardo 2014-02-05 23:05
  • Target version set to 3.0-rc0
dumganhar 2014-02-07 02:36
  • Description updated (diff)
zhangxm 2014-02-21 09:16
  • Target version changed from 3.0-rc0 to Candidate
dumganhar 2014-03-21 10:04
  • Status changed from New to Closed
  • % Done changed from 0 to 100

Applied in changeset commit:2dbeb712e688efc8360b824199ba6061ff063d57.

walzer@cocos2d-x.org 2014-05-04 07:05
  • Target version changed from Candidate to 116

Already be done in v3.0.
Good feature, especially for script bindings.

walzer@cocos2d-x.org 2014-05-04 07:07
  • Target version changed from 116 to 3.0-beta2

Atom PDF

Status:Closed
Start date:2014-02-05
Priority:Normal
Due date:
Assignee:-
% Done:

100%

Category:all
Target version:3.0-beta2