Skip to content

Commit

Permalink
+) Fix one memory leak (stop AnimationTimer) (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
streamingdv authored Nov 22, 2023
1 parent b251c26 commit 9b4490c
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,18 @@ abstract class GLCanvas(

private var useRenderDoc = false

private val animationTimer = object : AnimationTimer() {
override fun handle(now: Long) {
timerTick()
}
}

init {
visibleProperty().addListener { _, _, _ -> repaint() }
widthProperty().addListener { _, _, _ -> repaint() }
heightProperty().addListener { _, _, _ -> repaint() }

object: AnimationTimer(){
override fun handle(now: Long) {
timerTick()
}
}.start()
animationTimer.start()
}

protected abstract fun timerTick()
Expand Down Expand Up @@ -169,6 +171,7 @@ abstract class GLCanvas(
open fun dispose(){
disposed = true
animator = null
animationTimer.stop()
onDispose.dispatchEvent(createDisposeEvent())
}

Expand Down

0 comments on commit 9b4490c

Please sign in to comment.