Fix more JSB crash issues

This commit is contained in:
pandamicro
2016-02-04 00:47:47 +08:00
parent d5bc429e5e
commit d8dbbda902
5 changed files with 36 additions and 10 deletions
-4
View File
@@ -63,10 +63,6 @@ cc.Scene = cc.Class({
this._activeInHierarchy = false;
},
_onPreDestroy: function () {
this._sgNode.release();
},
_onHierarchyChanged: NIL,
_onColorChanged: NIL,
_onAnchorChanged: NIL,
@@ -29,6 +29,9 @@ var ComponentInSG = cc.Class({
* @private
*/
this._sgNode = this._createSgNode();
// retain immediately
// will be released in SceneGraphHelper.removeSgNode
this._sgNode.retain();
},
onLoad: function () {
+4 -2
View File
@@ -230,8 +230,10 @@ var Label = cc.Class({
this.node._sizeProvider = null;
}
// node should be resize whenever font changed
this._sgNode.on('load', this._updateNodeSize, this);
// node should be resize whenever font changed, needed only on web
if (!cc.sys.Native) {
this._sgNode.on('load', this._updateNodeSize, this);
}
},
onDestroy: function () {
+1 -2
View File
@@ -642,9 +642,8 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
},
destroy: function () {
_onPreDestroy: function () {
this._sgNode.release();
this._super();
},
// ABSTRACT INTERFACES
+28 -2
View File
@@ -79,7 +79,7 @@ jsbLabel.prototype.getTTFConfig = function () {
return this._ttfConfig;
};
jsbLabel.prototype.setContentSize = function(size, height) {
jsbLabel.prototype.setContentSize = function (size, height) {
if(height !== undefined){
this.setDimensions(size, height);
}
@@ -87,6 +87,32 @@ jsbLabel.prototype.setContentSize = function(size, height) {
this.setDimensions(size.width, size.height);
}
};
jsbLabel.prototype.setFontFileOrFamily = function (fontHandle) {
fontHandle = fontHandle || '';
var extName = cc.path.extname(fontHandle);
//specify font family name directly
if (extName === null) {
this._labelType = _ccsg.Label.Type.SystemFont;
this.setSystemFontName(fontHandle);
}
else {
//add resource path
fontHandle = cc.path.join(cc.loader.resPath, fontHandle);
if (extName === '.ttf') {
this._labelType = _ccsg.Label.Type.TTF;
this._ttfConfig.fontFilePath = fontHandle;
this.setTTFConfig(this._ttfConfig);
} else if (extName === '.fnt') {
//todo add bmfont here
this._labelType = _ccsg.Label.Type.BMFont;
this.setBMFontFilePath(fontHandle, cc.v2(0, 0), this.getBMFontSize());
}
}
};
cc.Label = function (string, fontHandle) {
fontHandle = fontHandle || "Arial";
var extName = cc.path.extname(fontHandle);
@@ -111,7 +137,7 @@ cc.Label = function (string, fontHandle) {
type = _ccsg.Label.Type.BMFont;
}
else {
label = jsbLabel.createWithSystemFont(string, fontHandle, 40);
label = jsbLabel.createWithSystemFont(string || '', fontHandle, 40);
type = _ccsg.Label.Type.SystemFont;
}
label._labelType = type;