improve error handling

This commit is contained in:
galister
2024-03-17 16:11:05 +01:00
parent 1d1230b1e7
commit 54dfb297ac
6 changed files with 67 additions and 45 deletions

View File

@@ -106,9 +106,7 @@ impl FontCache {
}
let pattern_str = format!("{PRIMARY_FONT}-{size}:style=bold:charset={cp:04x}");
let mut pattern =
OwnedPattern::from_str(&pattern_str).expect("Failed to create fontconfig pattern");
let mut pattern = OwnedPattern::from_str(&pattern_str).unwrap(); // safe because PRIMARY_FONT is const
self.fc
.substitute(&mut pattern, fontconfig::MatchKind::Pattern);
pattern.default_substitute();

View File

@@ -1,6 +1,5 @@
use std::{
f32::consts::PI,
io::Cursor,
ops::Add,
process::{self, Child},
sync::Arc,
@@ -8,7 +7,6 @@ use std::{
};
use glam::{Quat, Vec3A};
use rodio::{Decoder, Source};
use serde::Deserialize;
use crate::{
@@ -613,11 +611,8 @@ fn run_window(window: &Arc<str>, action: &WindowAction, app: &mut AppState) {
}
}
const THUMP_AUDIO_WAV: &'static [u8] = include_bytes!("../../res/380885.wav");
fn audio_thump(app: &mut AppState) {
if let Some(handle) = app.audio.get_handle() {
let wav = include_bytes!("../../res/380885.wav");
let cursor = Cursor::new(wav);
let source = Decoder::new_wav(cursor).unwrap();
let _ = handle.play_raw(source.convert_samples());
}
app.audio.play(THUMP_AUDIO_WAV);
}