From 9494b9d8b1a60059d4ec0b5021611bbb2878cf1d Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 26 Jul 2023 10:31:08 +0800 Subject: [PATCH] js: detect recursively call addOnRenderFinishedCallback --- doric-js/src/ui/panel.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doric-js/src/ui/panel.ts b/doric-js/src/ui/panel.ts index 7724743c..966776f9 100644 --- a/doric-js/src/ui/panel.ts +++ b/doric-js/src/ui/panel.ts @@ -58,6 +58,8 @@ export abstract class Panel { private __rendering__ = false + private callingRenderFinishedCallback = false + addHeadView(type: string, v: View) { let map = this.headviews.get(type) if (map) { @@ -257,13 +259,18 @@ export abstract class Panel { } onRenderFinished() { + this.callingRenderFinishedCallback = false this.onRenderFinishedCallback.forEach(e => { e() }) this.onRenderFinishedCallback.length = 0 + this.callingRenderFinishedCallback = true } addOnRenderFinishedCallback(cb: () => void) { + if (this.callingRenderFinishedCallback) { + loge("Do not call addOnRenderFinishedCallback recursively") + } this.onRenderFinishedCallback.push(cb) } } \ No newline at end of file