Ensure a new compiler state object is created every time.

Fixes #225.
dev/git-series/gccdum
Matt Godbolt 7 years ago
parent a804243b21
commit fda7e2414e

@ -161,14 +161,19 @@ define(function (require) {
this.eventHub.on('compileResult', this.onCompileResponse, this);
this.eventHub.on('selectLine', this.onSelectLine, this);
var compilerConfig = Components.getCompiler(this.id);
// NB a new compilerConfig needs to be created every time; else the state is shared
// between all compilers created this way. That leads to some nasty-to-find state
// bugs e.g. https://github.com/mattgodbolt/compiler-explorer/issues/225
var compilerConfig = _.bind(function () {
return Components.getCompiler(this.id);
}, this);
this.container.layoutManager.createDragSource(
this.domRoot.find('.btn.add-compiler'), compilerConfig);
this.domRoot.find('.btn.add-compiler'), compilerConfig());
this.domRoot.find('.btn.add-compiler').click(_.bind(function () {
var insertPoint = hub.findParentRowOrColumn(this.container) ||
this.container.layoutManager.root.contentItems[0];
insertPoint.addChild(compilerConfig);
insertPoint.addChild(compilerConfig());
}, this));
Sharing.initShareButton(this.domRoot.find('.share'), container.layoutManager);
@ -267,7 +272,7 @@ define(function (require) {
this.maybeEmitChange(true);
};
Editor.prototype.onCompiling = function(compilerId) {
Editor.prototype.onCompiling = function (compilerId) {
this.busyCompilers[compilerId] = true;
};

Loading…
Cancel
Save