Skip to content

Commit

Permalink
fixed #17016: wrong assertion if label is empty and uses BitmapFont (#…
Browse files Browse the repository at this point in the history
…18015)

* fixed #17016: wrong assertion if label is empty and uses BitmapFont
  • Loading branch information
dumganhar authored Dec 12, 2024
1 parent a7de5b9 commit 84790f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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

0 comments on commit 84790f5

Please sign in to comment.