Fix #781: race condition when destroying the editor right after setting data

This commit is contained in:
jos 2019-09-02 22:00:41 +02:00
parent a78adf6676
commit 671cad86fb
2 changed files with 9 additions and 4 deletions

View File

@ -3,6 +3,11 @@
https://github.com/josdejong/jsoneditor
## not yet published, version 7.0.2
- Fix #781: race condition when destroying the editor right after setting data.
## 2019-09-01, version 7.0.1
- Fix npm package missing `dist` folder.

View File

@ -711,18 +711,18 @@ textmode._setText = function (jsonText, clearHistory) {
if (this.aceEditor) {
// prevent emitting onChange events while setting new text
this.onChangeDisabled = true
this.aceEditor.setValue(text, -1)
this.onChangeDisabled = false
if (clearHistory) {
// prevent initial undo action clearing the initial contents
const me = this
setTimeout(() => {
me.aceEditor.session.getUndoManager().reset()
if (me.aceEditor) {
me.aceEditor.session.getUndoManager().reset()
}
}, 0)
}
this.onChangeDisabled = false
}
// validate JSON schema
this._debouncedValidate()