[librsvg] Handle.construct_new_from_gfile_sync() - removed; use the stream version everywhere
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Handle.construct_new_from_gfile_sync() - removed; use the stream version everywhere
- Date: Tue, 9 Apr 2019 16:44:34 +0000 (UTC)
commit 667f4327cf564ad62ed4ae410c8b4cc45ab0b805
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Apr 5 10:54:35 2019 -0600
Handle.construct_new_from_gfile_sync() - removed; use the stream version everywhere
rsvg_internals/src/c_api.rs | 20 ++++++++++++++------
rsvg_internals/src/handle.rs | 9 ---------
rsvg_internals/src/pixbuf_utils.rs | 13 +++++++++++--
3 files changed, 25 insertions(+), 17 deletions(-)
---
diff --git a/rsvg_internals/src/c_api.rs b/rsvg_internals/src/c_api.rs
index e0f323ca..a2f07853 100644
--- a/rsvg_internals/src/c_api.rs
+++ b/rsvg_internals/src/c_api.rs
@@ -8,13 +8,15 @@ use std::{f64, i32};
use libc;
+use gio::prelude::*;
+
use glib::object::ObjectClass;
use glib::subclass;
use glib::subclass::object::ObjectClassSubclassExt;
use glib::subclass::prelude::*;
use glib::translate::*;
use glib::value::{FromValue, FromValueOptional, SetValue};
-use glib::{ParamFlags, ParamSpec, StaticType, ToValue, Type, Value};
+use glib::{Cast, ParamFlags, ParamSpec, StaticType, ToValue, Type, Value};
use glib_sys;
use gobject_sys::{self, GEnumValue, GFlagsValue};
@@ -803,13 +805,19 @@ pub unsafe extern "C" fn rsvg_rust_handle_new_from_gfile_sync(
let rhandle = get_rust_handle(raw_handle);
- let file = from_glib_none(file);
+ let file = gio::File::from_glib_none(file);
let cancellable: Option<gio::Cancellable> = from_glib_none(cancellable);
- match rhandle
- .handle
- .construct_new_from_gfile_sync(&file, cancellable.as_ref())
- {
+ let res = file
+ .read(cancellable.as_ref())
+ .map_err(|e| LoadingError::from(e))
+ .and_then(|stream| {
+ rhandle
+ .handle
+ .construct_read_stream_sync(&stream.upcast(), Some(&file), cancellable.as_ref())
+ });
+
+ match res {
Ok(()) => raw_handle,
Err(e) => {
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index 52a9e931..83edf4c5 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -614,15 +614,6 @@ impl Handle {
pixbuf_from_surface(&surface)
}
- pub fn construct_new_from_gfile_sync(
- &self,
- file: &gio::File,
- cancellable: Option<&gio::Cancellable>,
- ) -> Result<(), LoadingError> {
- let stream = file.read(cancellable)?;
- self.construct_read_stream_sync(&stream.upcast(), Some(file), cancellable)
- }
-
pub fn construct_read_stream_sync(
&self,
stream: &gio::InputStream,
diff --git a/rsvg_internals/src/pixbuf_utils.rs b/rsvg_internals/src/pixbuf_utils.rs
index 2962838c..e13e1214 100644
--- a/rsvg_internals/src/pixbuf_utils.rs
+++ b/rsvg_internals/src/pixbuf_utils.rs
@@ -5,12 +5,14 @@ use cairo::{self, ImageSurface};
use gdk_pixbuf::{Colorspace, Pixbuf};
use gdk_pixbuf_sys;
use gio;
+use gio::prelude::*;
use glib::translate::*;
+use glib::Cast;
use glib_sys;
use libc;
use crate::c_api::RsvgDimensionData;
-use crate::error::{set_gerror, RenderingError};
+use crate::error::{set_gerror, LoadingError, RenderingError};
use crate::handle::{Handle, LoadFlags};
use crate::rect::IRect;
use crate::surface_utils::{
@@ -191,7 +193,14 @@ fn pixbuf_from_file_with_size_mode(
let file = gio::File::new_for_path(path);
let handle = Handle::new(LoadFlags::default());
- if let Err(e) = handle.construct_new_from_gfile_sync(&file, None) {
+ let cancellable: Option<&gio::Cancellable> = None;
+ if let Err(e) = file
+ .read(cancellable)
+ .map_err(|e| LoadingError::from(e))
+ .and_then(|stream| {
+ handle.construct_read_stream_sync(&stream.upcast(), Some(&file), None)
+ })
+ {
set_gerror(error, 0, &format!("{}", e));
return ptr::null_mut();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]