js: detect recursively call addOnRenderFinishedCallback
This commit is contained in:
parent
7ed8947671
commit
9494b9d8b1
@ -58,6 +58,8 @@ export abstract class Panel {
|
|||||||
|
|
||||||
private __rendering__ = false
|
private __rendering__ = false
|
||||||
|
|
||||||
|
private callingRenderFinishedCallback = false
|
||||||
|
|
||||||
addHeadView(type: string, v: View) {
|
addHeadView(type: string, v: View) {
|
||||||
let map = this.headviews.get(type)
|
let map = this.headviews.get(type)
|
||||||
if (map) {
|
if (map) {
|
||||||
@ -257,13 +259,18 @@ export abstract class Panel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onRenderFinished() {
|
onRenderFinished() {
|
||||||
|
this.callingRenderFinishedCallback = false
|
||||||
this.onRenderFinishedCallback.forEach(e => {
|
this.onRenderFinishedCallback.forEach(e => {
|
||||||
e()
|
e()
|
||||||
})
|
})
|
||||||
this.onRenderFinishedCallback.length = 0
|
this.onRenderFinishedCallback.length = 0
|
||||||
|
this.callingRenderFinishedCallback = true
|
||||||
}
|
}
|
||||||
|
|
||||||
addOnRenderFinishedCallback(cb: () => void) {
|
addOnRenderFinishedCallback(cb: () => void) {
|
||||||
|
if (this.callingRenderFinishedCallback) {
|
||||||
|
loge("Do not call addOnRenderFinishedCallback recursively")
|
||||||
|
}
|
||||||
this.onRenderFinishedCallback.push(cb)
|
this.onRenderFinishedCallback.push(cb)
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user