Skip to content

Commit

Permalink
Moved Node._isDisposed, Property.isDisposed & PhetioObject.phetioObje…
Browse files Browse the repository at this point in the history
…ctDisposed to PhetioObject.isDisposed, see phetsims/tandem#46
  • Loading branch information
samreid committed Nov 29, 2018
1 parent f1e27b9 commit 4618d52
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 27 deletions.
2 changes: 1 addition & 1 deletion js/display/Display.js
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ define( function( require ) {
* @returns {boolean}
*/
Display.assertSubtreeDisposed = function( node ) {
assert && assert( !node.isDisposed(), 'Disposed nodes should not be included in a scene graph to display.' );
assert && assert( !node.isDisposed, 'Disposed nodes should not be included in a scene graph to display.' );

if ( assert ) {
for ( var i = 0; i < node.children.length; i++ ) {
Expand Down
2 changes: 1 addition & 1 deletion js/input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ define( function( require ) {

for ( var i = trail.getLastInputEnabledIndex(); i >= 0; bubbles ? i-- : i = -1 ) {
var target = trail.nodes[ i ];
if ( target.isDisposed() ) {
if ( target.isDisposed ) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion js/nodes/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ define( function( require ) {
attachImageLoadListener: function() {
assert && assert( !this._imageLoadListenerAttached, 'Should only be attached to one thing at a time' );

if ( !this._isDisposed ) {
if ( !this.isDisposed ) {
this._image.addEventListener( 'load', this._imageLoadListener );
this._imageLoadListenerAttached = true;
}
Expand Down
26 changes: 3 additions & 23 deletions js/nodes/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,21 +515,6 @@ define( function( require ) {
// Initialize sub-components
this._picker = new Picker( this );

// Make sure Node's prototype dispose() is called when dispose() is called, and make sure that it isn't called
// more than once. See https://github.com/phetsims/scenery/issues/601.
// @private {boolean}
this._isDisposed = false;
if ( assert ) {
// Wrap the prototype dispose method with a check. NOTE: We will not catch devious cases where the dispose() is
// overridden after the Node constructor (which may happen).
var protoDispose = this.dispose;
this.dispose = function() {
assert && assert( !this._isDisposed, 'This Node has already been disposed, and cannot be disposed again' );
protoDispose.call( this );
assert && assert( this._isDisposed, 'Node.dispose() call is missing from an overridden dispose method' );
};
}

// @public (scenery-internal) {boolean} - There are certain specific cases (in this case due to a11y) where we need
// to know that a node is getting removed from its parent BUT that process has not completed yet. It would be ideal
// to not need this.
Expand Down Expand Up @@ -1892,7 +1877,7 @@ define( function( require ) {
var index = _.indexOf( this._inputListeners, listener );

// ensure the listener is in our list (ignore assertion for disposal, see https://github.com/phetsims/sun/issues/394)
assert && assert( this._isDisposed || index >= 0, 'Could not find input listener to remove' );
assert && assert( this.isDisposed || index >= 0, 'Could not find input listener to remove' );
if ( index >= 0 ) {
this._inputListeners.splice( index, 1 );
this._picker.onRemoveInputListener();
Expand Down Expand Up @@ -4999,10 +4984,7 @@ define( function( require ) {
*
* @returns {boolean}
*/
isDisposed: function() {
return this._isDisposed;
},
get disposed() { return this.isDisposed(); },
get disposed() { return this.isDisposed; },

/**
* Override for extra information in the fing output (from Display.getDebugHTML()).
Expand Down Expand Up @@ -5147,8 +5129,6 @@ define( function( require ) {
* @public
*/
dispose: function() {
// See constructor for Node disposal checks
this._isDisposed = true;

// remove all accessibility input listeners
this.disposeAccessibility();
Expand All @@ -5169,7 +5149,7 @@ define( function( require ) {
* techniques.
*/
disposeSubtree: function() {
if ( !this.isDisposed() ) {
if ( !this.isDisposed ) {
// makes a copy before disposing
var children = this.children;

Expand Down
2 changes: 1 addition & 1 deletion js/nodes/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ define( function( require ) {
assert && assert( !this._invalidShapeListenerAttached, 'We do not want to have two listeners attached!' );

// Do not attach shape listeners if we are disposed
if ( !this._isDisposed ) {
if ( !this.isDisposed ) {
this._shape.onStatic( 'invalidated', this._invalidShapeListener );
this._invalidShapeListenerAttached = true;
}
Expand Down

0 comments on commit 4618d52

Please sign in to comment.