Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a display error when Label's string was empty. #5266

Merged
merged 2 commits into from Aug 29, 2019

Conversation

@caryliu1999
Copy link
Contributor

commented Aug 28, 2019

修复论坛中用户反馈的Label置空之后仍会显示的问题:

https://forum.cocos.com/t/label/81190
https://forum.cocos.com/t/cc-label-string/82642/9

@@ -536,7 +536,7 @@ let Label = cc.Class({
this.node.on(cc.Node.EventType.COLOR_CHANGED, this._updateColor, this);

this._checkStringEmpty();
this._updateRenderData(true);
this._updateRenderData(!!this.string);

This comment has been minimized.

Copy link
@jareguo

jareguo Aug 28, 2019

Contributor

这里我不理解的是,统一 force update 的话,难道不应该是更正确吗?

This comment has been minimized.

Copy link
@caryliu1999

caryliu1999 Aug 28, 2019

Author Contributor

这里有两个问题:

  1. Label这里做的处理是,string为空就不做渲染了,updateRenderData(true)的话又会标记为需要渲染。
  2. updateRenderData(true)标记渲染之后,会进行重新绘制并进行texture更新,但是texture更新的时候(handleLoadedTexture)做了判断,image的width或者height为0( 判断用的是 !image.width )就不再update了,所以就用的还是旧的texture。

This comment has been minimized.

Copy link
@jareguo

jareguo Aug 28, 2019

Contributor

汗,感觉这些优化的点有点 hack。string 为空就不做渲染了,但是数据也得刷新 or 释放才对吧?另外建议 image size 为 0 也进行 update。

This comment has been minimized.

Copy link
@caryliu1999

caryliu1999 Aug 29, 2019

Author Contributor

嗯,已经把image size 为 0 的改为也进行update了。不做渲染,但是数据还是会刷新的,释放操作是节点在destroy的时候做的。

@jareguo jareguo merged commit 1a6cb96 into cocos-creator:v2.1.3 Aug 29, 2019
1 check passed
1 check passed
ci/circleci: test Your tests passed on CircleCI!
Details
caryliu1999 added a commit to caryliu1999/engine that referenced this pull request Aug 29, 2019
2youyou2 added a commit that referenced this pull request Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.