editing: Handle errors
This commit is contained in:
parent
5b51237203
commit
8345640757
5 changed files with 57 additions and 30 deletions
|
|
@ -18,6 +18,7 @@
|
|||
use tiling::RenderOptions;
|
||||
|
||||
use super::*;
|
||||
use crate::editing::preview::EditingError;
|
||||
|
||||
impl imp::LpImage {
|
||||
pub(super) fn apply_operations(
|
||||
|
|
@ -44,14 +45,16 @@ impl imp::LpImage {
|
|||
}
|
||||
|
||||
impl LpImage {
|
||||
pub fn set_operations(&self, operations: Option<Arc<glycin::Operations>>) {
|
||||
pub fn set_operations(
|
||||
&self,
|
||||
operations: Option<Arc<glycin::Operations>>,
|
||||
) -> Result<(), EditingError> {
|
||||
let imp = self.imp();
|
||||
|
||||
if operations.is_none() {
|
||||
imp.overwrite_dimensions.set(None);
|
||||
}
|
||||
imp.overwrite_dimensions.set(None);
|
||||
imp.operations.replace(operations);
|
||||
|
||||
// Let dimension rewrite by calculating the new image
|
||||
let tmp_snapshot = gtk::Snapshot::new();
|
||||
imp.active_frame_buffer().add_to_snapshot(
|
||||
&tmp_snapshot,
|
||||
|
|
@ -64,12 +67,14 @@ impl LpImage {
|
|||
);
|
||||
|
||||
if let Some(node) = tmp_snapshot.to_node() {
|
||||
imp.apply_operations(node, >k::Snapshot::new());
|
||||
imp.apply_operations(node, >k::Snapshot::new())?;
|
||||
} else {
|
||||
log::error!("Render node is empty");
|
||||
}
|
||||
|
||||
imp.configure_best_fit();
|
||||
self.queue_draw();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,9 @@ impl WidgetImpl for imp::LpImage {
|
|||
let tmp_snapshot = gtk::Snapshot::new();
|
||||
frame_buffer.add_to_snapshot(&tmp_snapshot, applicable_zoom, &render_options);
|
||||
if let Some(node) = tmp_snapshot.to_node() {
|
||||
self.apply_operations(node, snapshot);
|
||||
if let Err(err) = self.apply_operations(node, snapshot) {
|
||||
log::error!("Failed to apply operations to node: {err}");
|
||||
}
|
||||
} else {
|
||||
log::error!("Render node is empty");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue