From 6a2eab23aef9814d9f17daf2ae3b17941b2451ce Mon Sep 17 00:00:00 2001 From: jbphet Date: Fri, 12 May 2017 13:05:59 -0600 Subject: [PATCH] fixed a reference that was causing a memory leak, see #88 --- js/common/view/CoinTermCreatorNode.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js/common/view/CoinTermCreatorNode.js b/js/common/view/CoinTermCreatorNode.js index e646d21d..ae80b744 100644 --- a/js/common/view/CoinTermCreatorNode.js +++ b/js/common/view/CoinTermCreatorNode.js @@ -122,9 +122,6 @@ define( function( require ) { } } ); - // variables used by the input listener - var createdCoinTermView = null; - // Add the listener that will allow the user to click on this node and create a new coin term, and then position it // in the model. This works by forwarding the events it receives to the node that gets created in the view. this.addInputListener( { @@ -155,11 +152,14 @@ define( function( require ) { expressionManipulationModel.addCoinTerm( createdCoinTerm ); // get the view node that should have appeared in the view so that events can be forwarded to its drag handler - createdCoinTermView = expressionManipulationView.getViewForCoinTerm( createdCoinTerm ); + var createdCoinTermView = expressionManipulationView.getViewForCoinTerm( createdCoinTerm ); assert && assert( createdCoinTermView, 'unable to find coin term view' ); - // forward the event to the view node's drag handler - createdCoinTermView.dragHandler.startDrag( event ); + if ( createdCoinTermView ) { + + // forward the event to the view node's drag handler + createdCoinTermView.dragHandler.startDrag( event ); + } } } ); }