[niepce] rust: Fix result warnings on Cairo
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] rust: Fix result warnings on Cairo
- Date: Sat, 3 Jul 2021 16:26:59 +0000 (UTC)
commit 2e8a76ce400cb7337b03bef60a2284612dcb9404
Author: Hubert Figuière <hub figuiere net>
Date: Fri Jul 2 18:46:22 2021 -0400
rust: Fix result warnings on Cairo
- Added on_err_out!() macro
crates/npc-fwk/src/base/debug.rs | 15 +++++++++++++++
crates/npc-fwk/src/toolkit/widgets/rating_label.rs | 2 +-
niepce-main/src/niepce/ui/library_cell_renderer.rs | 14 +++++++-------
3 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/crates/npc-fwk/src/base/debug.rs b/crates/npc-fwk/src/base/debug.rs
index 7c13775..d25fa73 100644
--- a/crates/npc-fwk/src/base/debug.rs
+++ b/crates/npc-fwk/src/base/debug.rs
@@ -1,3 +1,18 @@
+#[macro_export]
+macro_rules! on_err_out {
+ ($e:expr) => {
+ if let Err(err) = $e {
+ err_out!(
+ "{}:{} Error '{}': {}",
+ file!(),
+ line!(),
+ stringify!($e),
+ err
+ );
+ }
+ };
+}
+
#[macro_export]
macro_rules! dbg_out {
( $( $x:expr ),* ) => {
diff --git a/crates/npc-fwk/src/toolkit/widgets/rating_label.rs
b/crates/npc-fwk/src/toolkit/widgets/rating_label.rs
index 7f445ab..88b03ca 100644
--- a/crates/npc-fwk/src/toolkit/widgets/rating_label.rs
+++ b/crates/npc-fwk/src/toolkit/widgets/rating_label.rs
@@ -197,7 +197,7 @@ impl RatingLabel {
} else {
cr.set_source_pixbuf(unstar, x, y);
}
- cr.paint();
+ on_err_out!(cr.paint());
x += w as f64;
}
}
diff --git a/niepce-main/src/niepce/ui/library_cell_renderer.rs
b/niepce-main/src/niepce/ui/library_cell_renderer.rs
index c964146..74c4cd9 100644
--- a/niepce-main/src/niepce/ui/library_cell_renderer.rs
+++ b/niepce-main/src/niepce/ui/library_cell_renderer.rs
@@ -228,10 +228,10 @@ impl LibraryCellRendererPriv {
cr.set_source_rgb(1.0, 1.0, 1.0);
cr.rectangle(x, y, w.into(), h.into());
- cr.stroke();
+ on_err_out!(cr.stroke());
cr.set_source_pixbuf(&pixbuf, x, y);
- cr.paint();
+ on_err_out!(cr.paint());
}
fn do_draw_flag(cr: &cairo::Context, flag: i32, r: &gdk::Rectangle) {
@@ -248,7 +248,7 @@ impl LibraryCellRendererPriv {
let x: f64 = (r.x + r.width - CELL_PADDING - w).into();
let y: f64 = (r.y + CELL_PADDING).into();
cr.set_source_pixbuf(&pixbuf, x, y);
- cr.paint();
+ on_err_out!(cr.paint());
}
fn do_draw_status(cr: &cairo::Context, status: FileStatus, r: &gdk::Rectangle) {
@@ -258,7 +258,7 @@ impl LibraryCellRendererPriv {
let x: f64 = (r.x + CELL_PADDING).into();
let y: f64 = (r.y + CELL_PADDING).into();
cr.set_source_pixbuf(&EMBLEMS.status_missing, x, y);
- cr.paint();
+ on_err_out!(cr.paint());
}
fn do_draw_format_emblem(cr: &cairo::Context, emblem: &Pixbuf, r: &gdk::Rectangle) -> i32 {
@@ -268,7 +268,7 @@ impl LibraryCellRendererPriv {
let x: f64 = (r.x + r.width - left).into();
let y: f64 = (r.y + r.height - CELL_PADDING - h).into();
cr.set_source_pixbuf(emblem, x, y);
- cr.paint();
+ on_err_out!(cr.paint());
left
}
@@ -279,11 +279,11 @@ impl LibraryCellRendererPriv {
cr.rectangle(x, y, LABEL_SIZE.into(), LABEL_SIZE.into());
cr.set_source_rgb(1.0, 1.0, 1.0);
- cr.stroke();
+ on_err_out!(cr.stroke());
cr.rectangle(x, y, LABEL_SIZE.into(), LABEL_SIZE.into());
let rgb: gdk::RGBA = colour.into();
cr.set_source_rgba(rgb.red, rgb.green, rgb.blue, rgb.alpha);
- cr.fill();
+ on_err_out!(cr.fill());
}
fn get_colour(&self, label_id: i32) -> Option<RgbColour> {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]