Skip to content

Commit

Permalink
DevTools: eliminate race condition in WI.StylesSourceMapping.
Browse files Browse the repository at this point in the history
If the style file was disposed, it should not do any other scheduled
actions.

BUG=608106
R=pfeldman

Review-Url: https://codereview.chromium.org/2016943004
Cr-Commit-Position: refs/heads/master@{#402326}
  • Loading branch information
aslushnikov authored and Commit bot committed Jun 27, 2016
1 parent f117125 commit c4fea64
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions front_end/bindings/StylesSourceMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,13 @@ WebInspector.StyleFile = function(uiSourceCode, mapping)
{
this._uiSourceCode = uiSourceCode;
this._mapping = mapping;
this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this);
this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
this._eventListeners = [
this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this),
this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this)
];
this._uiSourceCode.forceLoadOnCheckContent();
this._commitThrottler = new WebInspector.Throttler(WebInspector.StyleFile.updateTimeout);
this._terminated = false;
}

WebInspector.StyleFile.updateTimeout = 200;
Expand Down Expand Up @@ -365,6 +368,8 @@ WebInspector.StyleFile.prototype = {

_commitIncrementalEdit: function()
{
if (this._terminated)
return;
var promise = this._mapping._setStyleContent(this._uiSourceCode, this._uiSourceCode.workingCopy(), this._isMajorChangePending)
.then(this._styleContentSet.bind(this))
this._isMajorChangePending = false;
Expand Down Expand Up @@ -392,7 +397,9 @@ WebInspector.StyleFile.prototype = {

dispose: function()
{
this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this);
if (this._terminated)
return;
this._terminated = true;
WebInspector.EventTarget.removeEventListeners(this._eventListeners);
}
}

0 comments on commit c4fea64

Please sign in to comment.