[librsvg: 9/38] check_is_loaded(): turn into a method of Handle
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 9/38] check_is_loaded(): turn into a method of Handle
- Date: Fri, 25 Jan 2019 19:38:07 +0000 (UTC)
commit 9a8340e7cd01f27ad7e072c9dd085dbbef161e8a
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Jan 22 18:09:35 2019 -0600
check_is_loaded(): turn into a method of Handle
rsvg_internals/src/handle.rs | 62 ++++++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 31 deletions(-)
---
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index 0c0bcbbf..96aa8326 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -226,6 +226,30 @@ impl Handle {
Ok(())
}
+ fn check_is_loaded(self: &Handle) -> Result<(), RenderingError> {
+ match self.load_state.get() {
+ LoadState::Start => {
+ rsvg_g_warning("RsvgHandle has not been loaded");
+ Err(RenderingError::HandleIsNotLoaded)
+ }
+
+ LoadState::Loading => {
+ rsvg_g_warning("RsvgHandle is still loading; call rsvg_handle_close() first");
+ Err(RenderingError::HandleIsNotLoaded)
+ }
+
+ LoadState::ClosedOk => Ok(()),
+
+ LoadState::ClosedError => {
+ rsvg_g_warning(
+ "RsvgHandle could not read or parse the SVG; did you check for errors during the \
+ loading stage?",
+ );
+ Err(RenderingError::HandleIsNotLoaded)
+ }
+ }
+ }
+
fn load_options(&self) -> LoadOptions {
LoadOptions::new(self.load_flags.get(), self.base_url.borrow().clone())
}
@@ -721,30 +745,6 @@ pub unsafe extern "C" fn rsvg_handle_rust_set_testing(
rhandle.is_testing.set(from_glib(testing));
}
-fn check_is_loaded(handle: &Handle) -> Result<(), RenderingError> {
- match handle.load_state.get() {
- LoadState::Start => {
- rsvg_g_warning("RsvgHandle has not been loaded");
- Err(RenderingError::HandleIsNotLoaded)
- }
-
- LoadState::Loading => {
- rsvg_g_warning("RsvgHandle is still loading; call rsvg_handle_close() first");
- Err(RenderingError::HandleIsNotLoaded)
- }
-
- LoadState::ClosedOk => Ok(()),
-
- LoadState::ClosedError => {
- rsvg_g_warning(
- "RsvgHandle could not read or parse the SVG; did you check for errors during the \
- loading stage?",
- );
- Err(RenderingError::HandleIsNotLoaded)
- }
- }
-}
-
#[no_mangle]
pub unsafe extern "C" fn rsvg_handle_rust_read_stream_sync(
handle: *mut RsvgHandle,
@@ -820,7 +820,7 @@ pub unsafe extern "C" fn rsvg_handle_rust_get_geometry_sub(
) -> glib_sys::gboolean {
let rhandle = get_rust_handle(handle);
- if check_is_loaded(rhandle).is_err() {
+ if rhandle.check_is_loaded().is_err() {
return false.to_glib();
}
@@ -861,7 +861,7 @@ pub unsafe extern "C" fn rsvg_handle_rust_has_sub(
) -> glib_sys::gboolean {
let rhandle = get_rust_handle(handle);
- if check_is_loaded(rhandle).is_err() {
+ if rhandle.check_is_loaded().is_err() {
return false.to_glib();
}
@@ -883,7 +883,7 @@ pub unsafe extern "C" fn rsvg_handle_rust_render_cairo_sub(
let cr = from_glib_none(cr);
let id: Option<String> = from_glib_none(id);
- if check_is_loaded(rhandle).is_err() {
+ if rhandle.check_is_loaded().is_err() {
return false.to_glib();
}
@@ -920,7 +920,7 @@ pub unsafe extern "C" fn rsvg_handle_rust_get_pixbuf_sub(
let rhandle = get_rust_handle(handle);
let id: Option<String> = from_glib_none(id);
- if check_is_loaded(rhandle).is_err() {
+ if rhandle.check_is_loaded().is_err() {
return ptr::null_mut();
}
@@ -937,7 +937,7 @@ pub unsafe extern "C" fn rsvg_handle_rust_get_dimensions(
) {
let rhandle = get_rust_handle(handle);
- if check_is_loaded(rhandle).is_err() {
+ if rhandle.check_is_loaded().is_err() {
return;
}
@@ -967,7 +967,7 @@ pub unsafe extern "C" fn rsvg_handle_rust_get_dimensions_sub(
) -> glib_sys::gboolean {
let rhandle = get_rust_handle(handle);
- if check_is_loaded(rhandle).is_err() {
+ if rhandle.check_is_loaded().is_err() {
return false.to_glib();
}
@@ -1001,7 +1001,7 @@ pub unsafe extern "C" fn rsvg_handle_rust_get_position_sub(
) -> glib_sys::gboolean {
let rhandle = get_rust_handle(handle);
- if check_is_loaded(rhandle).is_err() {
+ if rhandle.check_is_loaded().is_err() {
return false.to_glib();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]