diff --git a/src/backend/pwnodeobject.rs b/src/backend/pwnodeobject.rs index dbd4ff5..5fbd8f9 100644 --- a/src/backend/pwnodeobject.rs +++ b/src/backend/pwnodeobject.rs @@ -613,9 +613,9 @@ impl PwNodeObject { } - pub(crate) fn node_property(&self, property: &str) -> T { + pub(crate) fn node_property(&self, property: &str) -> Option { let node = self.imp().wpnode.get().expect("node"); - node.pw_property(property).expect(property) + node.pw_property(property).ok() } } diff --git a/src/ui/sinkbox.rs b/src/ui/sinkbox.rs index ecaff7f..31ddb96 100644 --- a/src/ui/sinkbox.rs +++ b/src/ui/sinkbox.rs @@ -88,7 +88,7 @@ mod imp { let parent: &PwVolumeBox = obj.upcast_ref(); let node = parent.node_object().expect("nodeobj"); let node_name: String = if _togglebutton.is_active() { - node.node_property("node.name") + node.node_property("node.name").unwrap_or_default() } else { "".to_string() }; diff --git a/src/ui/volumebox.rs b/src/ui/volumebox.rs index 22012d2..4024f7c 100644 --- a/src/ui/volumebox.rs +++ b/src/ui/volumebox.rs @@ -10,6 +10,8 @@ use std::cell::{Cell, RefCell, OnceCell}; use wireplumber as wp; mod imp { + use crate::pwvucontrol_warning; + use super::*; #[derive(Default, gtk::CompositeTemplate, glib::Properties)] @@ -125,7 +127,11 @@ mod imp { let defaultnodesapi = manager.default_nodes_api(); let widget = self.obj(); let defaultnodesapi_closure = closure_local!(@watch widget, @strong item => move |defaultnodesapi: wp::plugin::Plugin| { - let media_class: String = item.node_property("media.class"); + let Some(media_class) = item.node_property::("media.class") + else { + pwvucontrol_warning!("{} is missing media.class property", item.name()); + return; + }; let id: u32 = defaultnodesapi.emit_by_name("get-default-node", &[&media_class]); wp::info!("default-nodes-api changed: new id {id}"); widget.imp().default_node.set(id);