Skip to content

Commit

Permalink
Fix crash when selecing Pro Audio profile.
Browse files Browse the repository at this point in the history
  • Loading branch information
saivert committed Nov 3, 2024
1 parent 18a7c42 commit d76ed4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/backend/pwnodeobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,9 @@ impl PwNodeObject {
}


pub(crate) fn node_property<T: FromPipewirePropertyString>(&self, property: &str) -> T {
pub(crate) fn node_property<T: FromPipewirePropertyString>(&self, property: &str) -> Option<T> {
let node = self.imp().wpnode.get().expect("node");
node.pw_property(property).expect(property)
node.pw_property(property).ok()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/sinkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};
Expand Down
8 changes: 7 additions & 1 deletion src/ui/volumebox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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::<String>("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);
Expand Down

0 comments on commit d76ed4f

Please sign in to comment.