From 86cc982982b4e448b01e5ed174c4d6adf4bc19e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 31 Jan 2021 11:01:47 +0200 Subject: [PATCH] examples: Check for cairo::Context::{save,restore}() failing --- examples/src/bin/overlay-composition.rs | 8 ++++---- examples/src/bin/pango-cairo.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/src/bin/overlay-composition.rs b/examples/src/bin/overlay-composition.rs index db40dd9f4..1156870f9 100644 --- a/examples/src/bin/overlay-composition.rs +++ b/examples/src/bin/overlay-composition.rs @@ -183,10 +183,10 @@ fn create_pipeline() -> Result { let cr = cairo::Context::new(&surface); - cr.save(); + cr.save().expect("Failed to save state"); cr.set_operator(cairo::Operator::Clear); cr.paint(); - cr.restore(); + cr.restore().expect("Failed to restore state"); // The image we draw (the text) will be static, but we will change the // transformation on the drawing context, which rotates and shifts everything @@ -207,7 +207,7 @@ fn create_pipeline() -> Result { // with this, we push our current transformation onto this stack - allowing us // to make temporary changes / render something / and then returning to the // previous transformations. - cr.save(); + cr.save().expect("Failed to save state"); let angle = (360. * f64::from(i)) / 10.0; let red = (1.0 + f64::cos((angle - 60.0) * PI / 180.0)) / 2.0; @@ -231,7 +231,7 @@ fn create_pipeline() -> Result { // Here we go one step up in our stack of transformations, removing any // changes we did to them since the last call to cr.save(); - cr.restore(); + cr.restore().expect("Failed to restore state"); } // Safety: The surface still owns a mutable reference to the buffer but our reference diff --git a/examples/src/bin/pango-cairo.rs b/examples/src/bin/pango-cairo.rs index 6f5a252b8..78a9e1901 100644 --- a/examples/src/bin/pango-cairo.rs +++ b/examples/src/bin/pango-cairo.rs @@ -167,7 +167,7 @@ fn create_pipeline() -> Result { // with this, we push our current transformation onto this stack - allowing us // to make temporary changes / render something / and then returning to the // previous transformations. - cr.save(); + cr.save().expect("Failed to save state"); let angle = (360. * f64::from(i)) / 10.0; let red = (1.0 + f64::cos((angle - 60.0) * PI / 180.0)) / 2.0; @@ -191,7 +191,7 @@ fn create_pipeline() -> Result { // Here we go one step up in our stack of transformations, removing any // changes we did to them since the last call to cr.save(); - cr.restore(); + cr.restore().expect("Failed to restore state"); } None