[librsvg: 5/90] DrawingCtx.with_discrete_layer(): Add a few missing map_err to restore the original context
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 5/90] DrawingCtx.with_discrete_layer(): Add a few missing map_err to restore the original context
- Date: Tue, 26 Mar 2019 19:12:28 +0000 (UTC)
commit 52397dc143e1cc3e9fb39036bde5d7540b33d39d
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Mar 8 10:16:07 2019 -0600
DrawingCtx.with_discrete_layer(): Add a few missing map_err to restore the original context
This sucks; it should use a try{} block.
rsvg_internals/src/drawing_ctx.rs | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 7fbab410..7992a08c 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -435,6 +435,9 @@ impl DrawingCtx {
original_cr.restore();
e
})?;
+ // FIXME: the .map_err() above is repeated below
+ // whenever this function uses "?". This should be
+ // replaced by "do catch".
}
let needs_temporary_surface = !(opacity == 1.0
@@ -448,7 +451,11 @@ impl DrawingCtx {
cairo::Format::ARgb32,
self.rect.width as i32,
self.rect.height as i32,
- )?;
+ )
+ .map_err(|e| {
+ original_cr.restore();
+ e
+ })?;
let cr = cairo::Context::new(&surface);
cr.set_matrix(affine);
@@ -466,7 +473,11 @@ impl DrawingCtx {
let child_surface = cairo::ImageSurface::from(self.cr.get_target()).unwrap();
let filter_result_surface = if let Some(filter_uri) = filter {
- self.run_filter(filter_uri, node, values, &child_surface)?
+ self.run_filter(filter_uri, node, values, &child_surface)
+ .map_err(|e| {
+ original_cr.restore();
+ e
+ })?
} else {
child_surface
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]