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 #17016: wrong assertion if label is empty and uses BitmapFont #18015

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cocos/2d/renderer/render-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ export class RenderData extends BaseRenderData {
// Hack Do not update pre frame
if (JSB && this.multiOwner === false) {
if (DEBUG) {
assert(this._renderDrawInfo.render2dBuffer.length === this._floatStride * this._data.length, 'Vertex count doesn\'t match.');
if (this._renderDrawInfo && this._renderDrawInfo.render2dBuffer) {
assert(this._renderDrawInfo.render2dBuffer.length === this._floatStride * this._data.length, 'Vertex count doesn\'t match.');
}
}
// sync shared buffer to native
this._renderDrawInfo.fillRender2dBuffer(this._data);
Expand Down
7 changes: 5 additions & 2 deletions cocos/2d/renderer/render-draw-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class RenderDrawInfo {
protected declare _uint32SharedBuffer: Uint32Array;

// SharedBuffer of pos/uv/color
protected declare _render2dBuffer: Float32Array;
protected _render2dBuffer: Float32Array | null = null;

constructor (nativeDrawInfo?: NativeRenderDrawInfo) {
this.init(nativeDrawInfo);
Expand All @@ -107,7 +107,7 @@ export class RenderDrawInfo {
return this._nativeObj;
}

get render2dBuffer (): Float32Array {
get render2dBuffer (): Float32Array | null {
return this._render2dBuffer;
}

Expand Down Expand Up @@ -301,6 +301,9 @@ export class RenderDrawInfo {

public fillRender2dBuffer (vertexDataArr: IRenderData[]): void {
if (JSB) {
if (!this._render2dBuffer) {
return;
}
const fillLength = Math.min(this._vbCount, vertexDataArr.length);
let bufferOffset = 0;
for (let i = 0; i < fillLength; i++) {
Expand Down
Loading