Removed all the setting properties to null in destroy methods that don't need them since destroy nullifies all properties.

This commit is contained in:
Scott Erickson 2014-03-24 14:42:56 -07:00
parent 53118984ff
commit 2c329a256f
17 changed files with 1 additions and 48 deletions

View file

@ -232,9 +232,4 @@ module.exports = class LevelLoader extends CocoClass
Backbone.Mediator.publish 'level-loader:progress-changed', progress: @progress()
@initWorld() if @allDone()
@trigger 'progress'
@trigger 'loaded-all' if @progress() is 1
destroy: ->
@world = null # don't hold onto garbage
@update = null
super()
@trigger 'loaded-all' if @progress() is 1

View file

@ -307,7 +307,6 @@ module.exports = class Camera extends CocoClass
destroy: ->
createjs.Tween.removeTweens @
@finishTween = null
super()
onZoomTo: (pos, time) ->

View file

@ -87,7 +87,6 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
mark.destroy() for name, mark of @marks
label.destroy() for name, label of @labels
@imageObject?.off 'animationend', @playNextAction
@playNextAction = null
@displayObject?.off()
clearInterval @effectInterval if @effectInterval
super()

View file

@ -100,12 +100,7 @@ module.exports = Surface = class Surface extends CocoClass
@stage.removeAllEventListeners()
@stage.enableDOMEvents false
@stage.enableMouseOver 0
@onFramesScrubbed = null
@onMouseMove = null
@onMouseDown = null
@tick = null
@canvas.off 'mousewheel', @onMouseWheel
@onMouseWheel = null
super()
setWorld: (@world) ->

View file

@ -42,7 +42,6 @@ module.exports = class CocoView extends Backbone.View
@stopListeningToShortcuts()
@undelegateEvents() # removes both events and subs
view.destroy() for id, view of @subviews
@modalClosed = null
$('#modal-wrapper .modal').off 'hidden.bs.modal', @modalClosed
@[key] = undefined for key, value of @
@destroyed = true

View file

@ -355,8 +355,6 @@ module.exports = class HUDView extends View
destroy: ->
@stage?.stopTalking()
@addMoreMessage = null
@animateEnterButton = null
clearInterval(@messageInterval) if @messageInterval
clearTimeout @hintNextSelectionTimeout if @hintNextSelectionTimeout
super()

View file

@ -123,5 +123,4 @@ module.exports = class LevelChatView extends View
destroy: ->
key.deleteScope('level')
clearInterval @clearOldMessagesInterval if @clearOldMessagesInterval
@clearOldMessages = null
super()

View file

@ -221,7 +221,3 @@ module.exports = class PlaybackView extends View
me.set('music', not me.get('music'))
me.save()
$(document.activeElement).blur()
destroy: ->
@onWindowResize = null
super()

View file

@ -94,9 +94,3 @@ module.exports = class CastButtonView extends View
spell.view.setAutocastDelay delay for spellKey, spell of @spells
@castOptions.find('a').each ->
$(@).toggleClass('selected', parseInt($(@).attr('data-delay')) is delay)
destroy: ->
@castButton.off 'click', @onCastButtonClick
@castOptions.find('a').off 'click', @onCastOptionsClick
@onCastOptionsClick = null
super()

View file

@ -162,5 +162,4 @@ module.exports = class DebugView extends View
destroy: ->
@ace?.removeEventListener "mousemove", @onMouseMove
@onMouseMove = null
super()

View file

@ -108,5 +108,4 @@ module.exports = class SpellListEntryView extends View
destroy: ->
@avatar?.destroy()
@hideThangs = null
super()

View file

@ -93,5 +93,4 @@ module.exports = class SpellListView extends View
destroy: ->
entry.destroy() for entry in @entries
@sortScoreForSpell = null
super()

View file

@ -575,13 +575,7 @@ module.exports = class SpellView extends View
@firepad?.dispose()
@ace?.commands.removeCommand command for command in @aceCommands
@ace?.destroy()
@ace = null
@aceDoc?.off 'change', @onCodeChangeMetaHandler
@aceDoc = null
@aceSession?.selection.off 'changeCursor', @onCursorActivity
@aceSession = null
@debugView?.destroy()
@spell = null
for fat in ['notifySpellChanged', 'notifyEditingEnded', 'notifyEditingBegan', 'onFirepadLoaded', 'onLoaded', 'toggleBackground', 'setRecompileNeeded', 'onCursorActivity', 'highlightCurrentLine', 'updateAether', 'onCodeChangeMetaHandler', 'recompileIfNeeded', 'currentAutocastHandler']
@[fat] = null
super()

View file

@ -83,6 +83,5 @@ module.exports = class ThangListView extends View
destroy: ->
entry.destroy() for entry in @entries
@sortScoreForThang = null
super()

View file

@ -219,5 +219,4 @@ module.exports = class TomeView extends View
destroy: ->
spell.destroy() for spellKey, spell of @spells
@worker?._close()
@worker = null
super()

View file

@ -472,9 +472,4 @@ module.exports = class PlayLevelView extends View
@bus?.destroy()
#@instance.save() unless @instance.loading
console.profileEnd?() if PROFILE_ME
@onLevelLoadError = null
@onLevelLoaderLoaded = null
@onSupermodelLoadedOne = null
@preloadNextLevel = null
@saveScreenshot = null
super()

View file

@ -476,9 +476,4 @@ module.exports = class SpectateLevelView extends View
delete window.world # not sure where this is set, but this is one way to clean it up
clearInterval(@pointerInterval)
console.profileEnd?() if PROFILE_ME
@onLevelLoadError = null
@onLevelLoaderLoaded = null
@onSupermodelLoadedOne = null
@preloadNextLevel = null
@saveScreenshot = null
super()