Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.49k stars 174 forks source link

[Kinc-hxcpp] Avoid `Image.unload` failed assertion through GC finalizer #1307

Closed Sanva closed 3 years ago

Sanva commented 3 years ago

Using Kinc hxcpp backend, if you unload a Kha image calling it's unload method and then you assign another object to the same reference [1], a few seconds later the GC will call finalize, calling unload again, which would trigger this assertion → https://github.com/Kode/Kha/blob/master/Backends/Kinc-hxcpp/kha/Image.hx#L432

I think this happens since this commit → https://github.com/Kode/Kha/commit/a354a90e7b5399a05fe9ba688651e14a92ba8945#diff-6d8eac6ed9e4907561b445a6ec521a8eefbe4801487048aeb552ac3443ce9085R406

[1] As done for example here → https://github.com/armory3d/zui/blob/master/Sources/zui/Zui.hx#L1655-L1658