Unverified Commit bd47a99a authored by Oleksandr Karpovich's avatar Oleksandr Karpovich Committed by GitHub

Add more ptr checks in AWT.kt (#810)

* Add more checks

* Update skiko/src/awtMain/kotlin/org/jetbrains/skiko/redrawer/WindowsOpenGLRedrawer.kt

* Update skiko/src/awtMain/kotlin/org/jetbrains/skiko/AWT.kt
Co-authored-by: 's avatarIgor Demin <igordmn@users.noreply.github.com>

* Update skiko/src/awtMain/kotlin/org/jetbrains/skiko/redrawer/WindowsOpenGLRedrawer.kt
Co-authored-by: 's avatarIgor Demin <igordmn@users.noreply.github.com>

---------
Co-authored-by: 's avatarIgor Demin <igordmn@users.noreply.github.com>
parent 30a5e9bb
......@@ -45,7 +45,10 @@ internal class DrawingSurface(
}
}
fun getInfo() = DrawingSurfaceInfo(ptr)
fun getInfo(): DrawingSurfaceInfo {
check(ptr != 0L) { "DrawingSurface.ptr is 0L. DrawingSurface might've been closed." }
return DrawingSurfaceInfo(ptr)
}
override fun close() {
freeDrawingSurface(awt, ptr)
......@@ -62,7 +65,13 @@ internal class DrawingSurfaceInfo(
}
private set
val platformInfo: Long get() = getPlatformInfo(ptr)
val platformInfo: Long
get() {
check(ptr != 0L) { "DrawingSurfaceInfo.ptr is 0L. DrawingSurfaceInfo might've been closed." }
return getPlatformInfo(ptr).also {
check(it != 0L) { "Can't get platformInfo" }
}
}
override fun close() {
freeDrawingSurfaceInfo(drawingSurface, ptr)
......
......@@ -13,7 +13,12 @@ internal class WindowsOpenGLRedrawer(
private val contextHandler = OpenGLContextHandler(layer)
override val renderInfo: String get() = contextHandler.rendererInfo()
private val device = layer.backedLayer.useDrawingSurfacePlatformInfo(::getDevice)
private val device: Long = layer.backedLayer.useDrawingSurfacePlatformInfo {
getDevice(it).also { devicePtr ->
check(devicePtr != 0L) { "Can't get device" }
}
}
private val context = createContext(device, layer.contentHandle, layer.transparency).also {
if (it == 0L) {
throw RenderException("Cannot create Windows GL context")
......
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