Skip to content

Commit

Permalink
dispose of buttons and NumberKeypad, #207
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Malley <[email protected]>
  • Loading branch information
pixelzoom committed Nov 2, 2018
1 parent 40a5d18 commit 5a8bf05
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions js/common/view/DoubleNumberLineAccordionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ define( function( require ) {
markerEditorAnimation && markerEditorAnimation.stop();
markerEditorNode.dispose();
doubleNumberLineNode.dispose();
eraserButton.dispose(); // workaround for memory leak https://github.com/phetsims/unit-rates/issues/207
undoButton.dispose(); // workaround for memory leak https://github.com/phetsims/unit-rates/issues/207
};

// @private required by prototype functions
Expand Down
15 changes: 14 additions & 1 deletion js/common/view/KeypadPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ define( function( require ) {
valueNode.text = valueString;
valueNode.center = valueBackgroundNode.center;
} );

// @private
this.disposeKeypadPanel = function() {
keypadNode.disposeSubtree(); // workaround for memory leak https://github.com/phetsims/unit-rates/issues/207
enterButton.dispose(); // workaround for memory leak https://github.com/phetsims/unit-rates/issues/207
};
}

unitRates.register( 'KeypadPanel', KeypadPanel );
Expand Down Expand Up @@ -181,5 +187,12 @@ define( function( require ) {
};
};

return inherit( Panel, KeypadPanel );
return inherit( Panel, KeypadPanel, {

// @public
dispose: function() {
this.disposeKeypadPanel();
Panel.prototype.dispose.call( this );
}
} );
} );
2 changes: 2 additions & 0 deletions js/common/view/MarkerEditorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ define( function( require ) {
this.disposeMarkerEditorNode = function() {
markerEditor.numeratorProperty.unlink( numeratorObserver );
markerEditor.denominatorProperty.unlink( denominatorObserver );
numeratorEditButton.dispose(); // workaround for memory leak https://github.com/phetsims/unit-rates/issues/207
denominatorEditButton.dispose(); // workaround for memory leak https://github.com/phetsims/unit-rates/issues/207
};

// @private fields required by prototype functions
Expand Down
1 change: 1 addition & 0 deletions js/shopping/view/ShoppingQuestionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ define( function( require ) {
// @private cleanup that's specific to this Node
this.disposeShoppingQuestionNode = function() {
question.guessProperty.unlink( guessObserver );
editButton.dispose(); // workaround for memory leak https://github.com/phetsims/unit-rates/issues/207
};
}

Expand Down
1 change: 1 addition & 0 deletions js/shopping/view/ShoppingQuestionsAccordionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ define( function( require ) {
assert && assert( child instanceof ShoppingQuestionNode );
child.dispose();
} );
refreshButton.dispose(); // workaround for memory leak https://github.com/phetsims/unit-rates/issues/207
};
}

Expand Down

0 comments on commit 5a8bf05

Please sign in to comment.