[librsvg: 20/22] handle: cleanup read_stream_sync



commit ce43e689f5620c9361143a2a7a97f46a293bea63
Author: Paolo Borelli <pborelli gnome org>
Date:   Tue Jan 8 13:58:07 2019 +0100

    handle: cleanup read_stream_sync

 rsvg_internals/src/handle.rs | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)
---
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index 9729c324..17a79ce5 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -164,37 +164,21 @@ impl Handle {
     ) -> Result<(), LoadingError> {
         self.load_state.set(LoadState::Loading);
 
-        self.read_stream_internal(handle, stream, cancellable)
-            .and_then(|_| {
-                self.load_state.set(LoadState::ClosedOk);
-                Ok(())
-            })
+        let svg = Svg::load_from_stream(&self.load_options(), handle, stream, cancellable)
             .map_err(|e| {
                 self.load_state.set(LoadState::ClosedError);
                 e
-            })
+            })?;
+
+        *self.svg.borrow_mut() = Some(Rc::new(svg));
+        self.load_state.set(LoadState::ClosedOk);
+        Ok(())
     }
 
     fn load_options(&self) -> LoadOptions {
         LoadOptions::new(self.load_flags.get(), self.base_url.borrow().clone())
     }
 
-    fn read_stream_internal(
-        &mut self,
-        handle: *mut RsvgHandle,
-        stream: gio::InputStream,
-        cancellable: Option<gio::Cancellable>,
-    ) -> Result<(), LoadingError> {
-        *self.svg.borrow_mut() = Some(Rc::new(Svg::load_from_stream(
-            &self.load_options(),
-            handle,
-            stream,
-            cancellable,
-        )?));
-
-        Ok(())
-    }
-
     pub fn write(&mut self, handle: *mut RsvgHandle, buf: &[u8]) {
         assert!(
             self.load_state.get() == LoadState::Start


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]