Skip to content

Commit

Permalink
Fix Splash example crash
Browse files Browse the repository at this point in the history
We can close the window during onRender
  • Loading branch information
igordmn committed Jan 26, 2021
1 parent 034e408 commit f56cfc9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ open class SkiaLayer : HardwareLayer() {

renderer?.onRender(canvas, pictureWidth, pictureHeight, nanoTime)

check(!isDisposed)

synchronized(pictureLock) {
picture?.instance?.close()
val picture = pictureRecorder.finishRecordingAsPicture()
this.picture = PictureHolder(picture, pictureWidth, pictureHeight)
// we can dispose layer during onRender
if (!isDisposed) {
synchronized(pictureLock) {
picture?.instance?.close()
val picture = pictureRecorder.finishRecordingAsPicture()
this.picture = PictureHolder(picture, pictureWidth, pictureHeight)
}
}
}

Expand Down

0 comments on commit f56cfc9

Please sign in to comment.