]> git.scottworley.com Git - srec/blobdiff - srec.py
Stop streams on exit
[srec] / srec.py
diff --git a/srec.py b/srec.py
index 7ef4d466514f0d5a0f4fe810697e91d66312dcb3..b3abee1e9ba0fa558211d8b419b87f369ffd1630 100644 (file)
--- a/srec.py
+++ b/srec.py
@@ -128,15 +128,16 @@ def on_start_button(_: Gtk.Button, stack: Gtk.Stack) -> None:
 
 def stop_streams() -> None:
     global recording, sharing  # pylint: disable=global-statement
 
 def stop_streams() -> None:
     global recording, sharing  # pylint: disable=global-statement
-    assert recording is not None
-    recording.stop()
-    recording = None
+    if recording is not None:
+        recording.stop()
+        recording = None
     if sharing is not None:
         sharing.stop()
         sharing = None
 
 
 def on_stop_button(_: Gtk.Button, stack: Gtk.Stack) -> None:
     if sharing is not None:
         sharing.stop()
         sharing = None
 
 
 def on_stop_button(_: Gtk.Button, stack: Gtk.Stack) -> None:
+    assert recording is not None
     stop_streams()
     stack.set_visible_child_name("not_recording")
 
     stop_streams()
     stack.set_visible_child_name("not_recording")
 
@@ -190,6 +191,7 @@ def main() -> None:
     app = Gtk.Application(application_id='net.chkno.srec')
     app.connect('activate', on_activate)
     app.run(None)
     app = Gtk.Application(application_id='net.chkno.srec')
     app.connect('activate', on_activate)
     app.run(None)
+    stop_streams()
 
 
 if __name__ == '__main__':
 
 
 if __name__ == '__main__':