Open cmaves opened 4 years ago
:thinking:
The issue here is pervasive with the xcb
crate as well I feel, there are two options:
Rc<xcb::Connection>
or Arc<xcb::Connection>
, but then without HKTs picking which one of the two becomes ugly, so it'd likely have to be an Arc<xcb::Connection>
which is overhead.shm::Image
which makes the API more complex and makes it hard to store an shm::Image
into other types.Which way of suffering would you prefer in your code for instance? If you showed me how you're using shm::Image
I can see what the least painful solution is.
I was using it in a crate to set the root window's background pixmap. I took your image module and changed it to use lifetimes but I imagine the Rc<xcb::Connection>
or Arc<xcb::Connection>
would be more ergonomic for other users of the crate. Migrating existing dependent crates to use a Arc<xcb::Connection>
solution would likely be trivial but satisfying a new lifetime requirement could be pain, especially you're using threading.
If the
xcb::Connection
, that is used to create thexcb::image::shm::Image
, is dropped before theImage
then a double free will occur causing a crash.A short program demonstrating this:
PS: Thanks for making this crate. Its awesome.