Unverified Commit 47341c43 authored by Elijah Semyonov's avatar Elijah Semyonov Committed by GitHub

Throw exception instead of force unwrapping Metal handles when initialising MetalRedrawer. (#704)

* Throw exception instead of force unwrapping Metal handles

* Update skiko/src/macosMain/kotlin/org/jetbrains/skiko/redrawer/MetalRedrawer.macos.kt
Co-authored-by: 's avatarIvan Matkov <ivan.matkov@jetbrains.com>

* Update based on review feedback

* Remove redundant this

* Remove unneeded imports

---------
Co-authored-by: 's avatarElijah Semyonov <elijah.semyonov@jetbrains.com>
Co-authored-by: 's avatarIvan Matkov <ivan.matkov@jetbrains.com>
parent 38b8fb20
......@@ -28,8 +28,8 @@ internal class MetalRedrawer(
override val renderInfo: String get() = contextHandler.rendererInfo()
private var isDisposed = false
internal val device = MTLCreateSystemDefaultDevice()!!
private val queue = device.newCommandQueue()!!
internal val device = MTLCreateSystemDefaultDevice() ?: throw IllegalStateException("Metal is not supported on this system")
private val queue = device.newCommandQueue() ?: throw IllegalStateException("Couldn't create Metal command queue")
private var currentDrawable: CAMetalDrawableProtocol? = null
private val metalLayer = MetalLayer()
private val frameListener: NSObject = FrameTickListener {
......
......@@ -39,8 +39,8 @@ internal class MacOsMetalRedrawer(
override val renderInfo: String get() = contextHandler.rendererInfo()
private var isDisposed = false
internal val device = MTLCreateSystemDefaultDevice()!!
private val queue = device.newCommandQueue()!!
internal val device = MTLCreateSystemDefaultDevice() ?: throw IllegalStateException("Metal is not supported on this system")
private val queue = device.newCommandQueue() ?: throw IllegalStateException("Couldn't create Metal command queue")
private var currentDrawable: CAMetalDrawableProtocol? = null
private val metalLayer = MetalLayer()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment