joa-quim/IUP.jl

add gc-safety to unsafe objref functions

Opened this issue · 0 comments

before grabbing a naked pointer to an object, you need to put it into a global array to protect it from being deleted.

for an example, see https://github.com/JuliaLang/Gtk.jl/blob/8318ad3481acf30cf4ccecc2f984a27f8ce324a5/src/GLib/gtype.jl#L322-L337
although, in v0.4, you should probably also wrap the object in a Ref object so that you can use isbits objects too (updating that Gtk code is on my todo list). as a bonus, ccall and cfunction know how to convert to/from this type and a pointer to this type, so you typically shouldn't need to do so explicitly.

ref. https://github.com/joa-quim/IUP.jl/blob/e670b2fc6e89b26b961dcdf801fbd8e1e1f75c99/src/handlegraphics.jl