Skip to content

Commit

Permalink
Ensure a new compiler state object is created every time.
Browse files Browse the repository at this point in the history
Fixes #225.
  • Loading branch information
mattgodbolt committed Jan 7, 2017
1 parent a804243 commit fda7e24
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions static/editor.js
Expand Up @@ -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);
Expand Down Expand Up @@ -267,7 +272,7 @@ define(function (require) {
this.maybeEmitChange(true);
};

Editor.prototype.onCompiling = function(compilerId) {
Editor.prototype.onCompiling = function (compilerId) {
this.busyCompilers[compilerId] = true;
};

Expand Down

0 comments on commit fda7e24

Please sign in to comment.