gtk-rs / gir

Tool to generate rust bindings and user API for glib-based libraries
https://gtk-rs.org/gir/book/
MIT License
238 stars 107 forks source link

Don't derive Copy for FFI structs/unions that contain pointers #1048

Open sdroege opened 3 years ago

sdroege commented 3 years ago

In https://github.com/gtk-rs/gir/pull/415 we started deriving Copy for all FFI structs and unions. This can easily lead to double frees and related problems because it can be non-obvious from the code that a value is actually copied instead of being moved.

https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/310 is an example of that.

We should probably stop deriving Copy for such structs/unions with pointers. Clone is still fine as that has to happen explicitly.

@EPashkin @GuillaumeGomez @bilelmoussaoui Opinions?

GuillaumeGomez commented 3 years ago

I strongly agree.