diff --git a/rust/pm-grid/src/main.rs b/rust/pm-grid/src/main.rs index 2e5c2a9..151daf0 100644 --- a/rust/pm-grid/src/main.rs +++ b/rust/pm-grid/src/main.rs @@ -216,6 +216,7 @@ fn build_setlists(user: Vec) -> Vec { }) .collect(); v.extend(user); + v.retain(|s| !s.items.is_empty()); // never keep an empty set list (would `% 0` in load/next) v } @@ -946,6 +947,12 @@ impl App { /// Build `F0 7D F7`, packetize into 4-byte USB-MIDI events, queue them. fn sx_send(&mut self, op: u8, text: &str) { + // Bound the TX queue: if the host stopped draining MIDI-IN (e.g. editor closed without a BYE + // while sync_armed), drop the message rather than grow the heap forever. The 5 s heartbeat + // re-syncs once the host returns. + if self.tx_q.len() > 256 { + return; + } let mut f: Vec = Vec::with_capacity(text.len() + 4); f.push(0xF0); f.push(0x7D);