Index: third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js b/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js |
index 64296ff8ac314a4bca495a06633d3c87e85d6b1a..d02ce0a5f8de7668078bb081ce7cd6fe1b16fb33 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js |
+++ b/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js |
@@ -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; |
@@ -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; |
@@ -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); |
} |
} |