[bugfix] Guard against out-of-order destruction

For unknown reasons, some of the event handlers in the reflist class
can be called when the model is already partially destroyed.  I
removed some guard logic in I0809df9d3c24fdd5fe which turns out to be
necessary, so I'm adding it here explicitly.

To reproduce the bug, try deleting the reflist in VE.

Bug: T375049
Change-Id: I33e6526cdf535eddaaf8ae506243a5898bd15676
This commit is contained in:
Adam Wight 2024-09-18 09:32:24 +02:00
parent 94d78fa268
commit 8534007aee

View file

@ -104,6 +104,9 @@ ve.ce.MWReferencesListNode.prototype.onTeardown = function () {
// Parent method
ve.ce.MWReferencesListNode.super.prototype.onTeardown.call( this );
if ( !this.getModel() || !this.getModel().getDocument() ) {
return;
}
const internalList = this.getModel().getDocument().getInternalList();
const listNode = internalList.getListNode();
@ -119,6 +122,9 @@ ve.ce.MWReferencesListNode.prototype.onTeardown = function () {
* @param {string[]} groupsChanged A list of groups which have changed in this transaction
*/
ve.ce.MWReferencesListNode.prototype.onInternalListUpdate = function ( groupsChanged ) {
if ( !this.getModel() ) {
return;
}
// Only update if this group has been changed
if ( groupsChanged.indexOf( this.getModel().getAttribute( 'listGroup' ) ) !== -1 ) {
this.modified = true;