refactor: remove unnecessary unwraps

WIP/draft
drendog 2024-08-21 01:02:58 +02:00
parent 3f499429d7
commit f310825194
Signed by: dwenya
GPG Key ID: 8DD77074645332D0
3 changed files with 12 additions and 4 deletions

View File

@ -30,6 +30,7 @@ pedantic = { level = "warn", priority = -1 }
clone_on_ref_ptr = "warn"
multiple-crate-versions = "allow"
module_name_repetitions = "allow"
unwrap_used = "warn"
[dependencies]
anyhow = "1.0.86"

View File

@ -56,7 +56,12 @@ impl WindowingSystem {
let pointer = Rc::new(seat.get_pointer(&event_queue.handle(), ()));
let mut state_builder = WindowStateBuilder::new()
.component_definition(config.component_definition.take().unwrap())
.component_definition(
config
.component_definition
.take()
.context("Component definition is required")?,
)
.surface(Rc::clone(&surface))
.layer_surface(Rc::clone(&layer_surface))
.pointer(Rc::clone(&pointer))
@ -218,7 +223,7 @@ impl WindowingSystem {
.read()
.map_err(|e| anyhow::anyhow!("Failed to read events: {}", e))?;
}
connection.flush().unwrap();
connection.flush()?;
event_queue.dispatch_pending(shared_data)?;

View File

@ -4,7 +4,7 @@ use slint_interpreter::ComponentDefinition;
use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1;
use wayland_client::protocol::{wl_pointer::WlPointer, wl_surface::WlSurface};
use crate::rendering::{femtovg_window::FemtoVGWindow, slint_platform::CustomSlintPlatform};
use anyhow::Result;
use anyhow::{Context, Result};
use super::WindowState;
@ -77,7 +77,9 @@ impl WindowStateBuilder {
}
pub fn build(self) -> Result<WindowState> {
let platform = CustomSlintPlatform::new(Rc::clone(self.window.as_ref().unwrap()));
let platform = CustomSlintPlatform::new(Rc::clone(
self.window.as_ref().context("Window is required")?,
));
slint::platform::set_platform(Box::new(platform))
.map_err(|e| anyhow::anyhow!("Failed to set platform: {:?}", e))?;