[librsvg: 11/45] Handle: store a Session




commit 4231dc23e806bf53f1a1304851421d1a1e90bb07
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Aug 19 16:58:15 2022 -0500

    Handle: store a Session
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/731>

 src/api.rs    | 1 +
 src/handle.rs | 6 ++++++
 2 files changed, 7 insertions(+)
---
diff --git a/src/api.rs b/src/api.rs
index c63fa9ea4..b8ea4e879 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -214,6 +214,7 @@ impl Loader {
 
         Ok(SvgHandle {
             handle: Handle::from_stream(
+                self.session.clone(),
                 &load_options,
                 stream.as_ref(),
                 cancellable.map(|c| c.as_ref()),
diff --git a/src/handle.rs b/src/handle.rs
index 2480eb9a8..541e38777 100644
--- a/src/handle.rs
+++ b/src/handle.rs
@@ -2,6 +2,8 @@
 //!
 //! This module provides the primitives on which the public APIs are implemented.
 
+use std::sync::Arc;
+
 use crate::accept_language::UserLanguage;
 use crate::bbox::BoundingBox;
 use crate::css::{Origin, Stylesheet};
@@ -12,6 +14,7 @@ use crate::error::{DefsLookupErrorKind, LoadingError, RenderingError};
 use crate::length::*;
 use crate::node::{CascadedValues, Node, NodeBorrow};
 use crate::rect::Rect;
+use crate::session::Session;
 use crate::structure::IntrinsicDimensions;
 use crate::url_resolver::{AllowedUrl, UrlResolver};
 
@@ -79,17 +82,20 @@ impl LoadOptions {
 ///
 /// [`from_stream`]: #method.from_stream
 pub struct Handle {
+    session: Arc<Session>,
     document: Document,
 }
 
 impl Handle {
     /// Loads an SVG document into a `Handle`.
     pub fn from_stream(
+        session: Arc<Session>,
         load_options: &LoadOptions,
         stream: &gio::InputStream,
         cancellable: Option<&gio::Cancellable>,
     ) -> Result<Handle, LoadingError> {
         Ok(Handle {
+            session,
             document: Document::load_from_stream(load_options, stream, cancellable)?,
         })
     }


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