loop: prevent stopping a stopped loop

This commit is contained in:
Tim Culverhouse 2024-07-01 11:17:44 -05:00
parent b68864c3ba
commit 49ed160268

View file

@ -50,6 +50,8 @@ pub fn Loop(comptime T: type) type {
/// stops reading from the tty. /// stops reading from the tty.
pub fn stop(self: *Self) void { pub fn stop(self: *Self) void {
// If we don't have a thread, we have nothing to stop
if (self.thread == null) return;
self.should_quit = true; self.should_quit = true;
// trigger a read // trigger a read
self.vaxis.deviceStatusReport(self.tty.anyWriter()) catch {}; self.vaxis.deviceStatusReport(self.tty.anyWriter()) catch {};