From 277e539abd623036a2a04a9e0de16a23b4f9f9d0 Mon Sep 17 00:00:00 2001 From: bordun Date: Wed, 4 Sep 2019 15:44:19 +0200 Subject: [PATCH] widgets: prevent reCreateWidget from being called by a destroyed widget instace (#556) --- CHANGELOG.md | 1 + src/client/app/managers/state.js | 7 +------ src/client/app/widgets/common/widget.js | 4 +++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e92871a..0d07d1ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - bug fixes - keys: prevent default browser actions when a combo is bound to a widget (for example print dialog with ctrl+p) - xy: broken `doubleTap` + - widget: error when two sibling widgets have a non-dynamic property depending on each others and on another widget at the same time ## 0.47.3 diff --git a/src/client/app/managers/state.js b/src/client/app/managers/state.js index c3b6c009..7045ebcd 100644 --- a/src/client/app/managers/state.js +++ b/src/client/app/managers/state.js @@ -21,8 +21,6 @@ var StateManager = class StateManager { this.valueNewPropQueue = {} this.queueCounter = 0 - this.flushTimeout = null - } get(filter) { @@ -233,10 +231,7 @@ var StateManager = class StateManager { decrementQueue() { this.queueCounter-- if (this.queueCounter == 0) { - if (this.flushTimeout) clearTimeout(this.flushTimeout) - this.flushTimeout = setTimeout(()=>{ - this.flush() - }) + this.flush() } } diff --git a/src/client/app/widgets/common/widget.js b/src/client/app/widgets/common/widget.js index d00d91a0..69ceb37d 100644 --- a/src/client/app/widgets/common/widget.js +++ b/src/client/app/widgets/common/widget.js @@ -147,6 +147,7 @@ class Widget extends EventEmitter { this.hash = nanoid('abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXYZ', 10) this.children = [] this.reCreateOptions = options.reCreateOptions + this.removed = false this.createPropsCache() @@ -924,12 +925,13 @@ class Widget extends EventEmitter { reCreateWidget(options={}){ - return updateWidget(this, options) + if (!this.removed) return updateWidget(this, options) } onRemove(){ + this.removed = true widgetManager.off(undefined, undefined, this) this.removeOscReceivers()