Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
ImageSurface: return a Result<ImageSurface, Status> from the creation functions #146
When Cairo gets asked to create a surface, it will always return a
For the Rust-side surface creation functions, we now return a
This means that "image_surface = from_glib_full(ptr)" needs to be
I've pushed the changes to image_surface_png.rs and win32_surface.rs. A couple of notes:
There are new tests and they pass. However, for an invalid PNG I'm getting different errors from Cairo depending on what byte on the PNG data I make invalid: sometimes I get NoMemory, sometimes ReadError... I thought those would always give PngError? Maybe this is a bug in Cairo or libpng?
I can't test the changes to win32_surface.rs, unfortunately. I'm not sure that e.g. Win32Surface::create() is correct, as cairo_win32_surface_create() can return NULL as well as a Cairo error surface in case of errors. Unfortunately I don't know the correct semantics there to give the correct error type in the Rust API.
Thanks for merging and updating the examples!
I found the reason for the NoMemory error in case of a corrupted PNG. It's a bug in Cairo (not that libpng makes its life particularly easy). I've just filed https://bugs.freedesktop.org/show_bug.cgi?id=102142 about this.