Skip to content

Commit

Permalink
Remove unwrap/expect and replace with real error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
gamingrobot committed Aug 12, 2022
1 parent 037a042 commit 832d11a
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 108 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ rosc = "0.8.0"
crossbeam-channel = "0.5.4"
parking_lot = "0.12.0"
rubato = "0.12.0"
anyhow = "1.0"

[patch."https://github.com/robbert-vdh/baseview.git"]
baseview = { git = 'https://github.com/gamingrobot/baseview', branch = "focus-hack" } # hack to capture input focus on left click
Expand Down
35 changes: 24 additions & 11 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use nih_plug_vizia::{assets, create_vizia_editor, ViziaState};
use std::sync::Arc;

use crate::param_view::ParamView;
use crate::{DawOutParams, OscChannelMessageType, OscConnectionType, OscAddressBaseType};
use crate::{DawOutParams, OscAddressBaseType, OscChannelMessageType, OscConnectionType};

/// VIZIA uses points instead of pixels for text
const POINT_SCALE: f32 = 0.75;
Expand Down Expand Up @@ -48,19 +48,31 @@ impl Model for DawOutEditor {
*self.params.osc_address_base.write() = self.osc_address_base.clone();
}
DawOutEditorEvent::ConnectionChange => {
nih_trace!("Connection Changed {}:{}", self.osc_server_address, self.osc_server_port);
self.sender.send(OscChannelMessageType::ConnectionChange(OscConnectionType {
ip: self.osc_server_address.clone(),
port: self.osc_server_port,
}))
.unwrap();
nih_trace!(
"Connection Changed {}:{}",
self.osc_server_address,
self.osc_server_port
);
let send_result =
self.sender
.send(OscChannelMessageType::ConnectionChange(OscConnectionType {
ip: self.osc_server_address.clone(),
port: self.osc_server_port,
}));
if send_result.is_err() {
nih_error!("Failed to send ConnectionChange update {:?}", send_result.unwrap_err());
}
}
DawOutEditorEvent::AddressBaseChange => {
nih_trace!("AddressBase Changed: {}", self.osc_address_base);
self.sender.send(OscChannelMessageType::AddressBaseChange(OscAddressBaseType {
address: self.osc_address_base.clone()
}))
.unwrap();
let send_result = self.sender.send(OscChannelMessageType::AddressBaseChange(
OscAddressBaseType {
address: self.osc_address_base.clone(),
},
));
if send_result.is_err() {
nih_error!("Failed to send AddressBaseChange update {:?}", send_result.unwrap_err());
}
}
});
}
Expand Down Expand Up @@ -90,6 +102,7 @@ pub(crate) fn create(

//ResizeHandle::new(cx);

//TODO: add error view for errors
//TODO: cleanup styling, split settings into another view?
VStack::new(cx, |cx| {
Label::new(cx, "DAW Out")
Expand Down
Loading

0 comments on commit 832d11a

Please sign in to comment.