-
-
Notifications
You must be signed in to change notification settings - Fork 58
SvgSurface: make filename param optional #294
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@GuillaumeGomez Any idea why the CI fails with
It builds and works fine locally here. |
Try to change your code as follow: path.map(|s| s.as_str()).to_glib_none().0 |
My bad! I was running the tests without |
It fails because tests are run without |
Oh then it depends: is it supposed to be run even without glib or not? If so, please don't use |
It doesn't need to. In such case, what I'm supposed to do? |
Like this: let c_str = CString::new(c_str).unwrap();
// then:
c_str.as_ptr(); |
lgtm |
src/svg.rs
Outdated
#[cfg(windows)] | ||
let path = { | ||
// Based on GLib path to C | ||
let path_str = path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that path
is not an Option
and already a Path
. Needs the map()
, as_ref()
part from above too
src/svg.rs
Outdated
CString::new(p.as_ref().as_os_str().as_bytes()) | ||
.expect("Invalid path with NULL bytes") | ||
}); | ||
path.map(|p| p.as_ptr()).unwrap_or(ptr::null()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path will be freed once this block is done, and then you store a dangling pointer in path in the outer scope. Just return the Option<CString>
from this block, and do the as_ptr()
part for both Windows/UNIX just before calling the C function.
Looks good for real now :) |
Then I'll merge for real once CI passed. 😆 |
@bilelmoussaoui Thanks, 👍 |
@sdroege, @GuillaumeGomez Maybe we need to make these function public someday |
@EPashkin Oh indeed! Do you mind opening an issue for it please? So it can be done for the next release. :) |
That would not help here as otherwise cairo would have to always depend on glib |
@sdroege Agree about this case, but IMHO here also better add separate |
I don't see a valid reason to do that as the function won't be used anywhere else but I agree it makes that part of code less readable. The failing tests are not related to this change I think. |
@bilelmoussaoui Why you think that it not related?
|
IMHO test with |
Because I had that issue once, tried to reproduce it and it was gone the next time I ran the tests. Yeah a test with None will be good. Will add that. |
Still fails to write the output file, on Windows and macOS but not on Linux. |
On Windows |
Old version works on |
Per the docs https://www.cairographics.org/manual/cairo-SVG-Surfaces.html This allows drawing parts of a SVG file without saving it to a tmp file.
CI passed |
Great, let's get it in then :) |
Thanks! |
Per the docs https://www.cairographics.org/manual/cairo-SVG-Surfaces.html
This allows drawing parts of a SVG file without saving it to a tmp file.
I'm not sure if what I did is right or not :P
Fixes #293