fixed issue where usrp siggen continued to transmit after program exit
[debian/gnuradio] / gr-utils / src / python / usrp_siggen_gui.py
index 40848fbeee3aa0d7764de5f5d92a63731084b711..47d47bdb3def7ed0eb4159b58913b41d359cb597 100755 (executable)
@@ -284,7 +284,7 @@ class app_gui(pubsub):
         self.vbox.AddSpacer(5)
         self.vbox.AddStretchSpacer()
 
-if __name__ == "__main__":
+def main():
     try:
         # Get command line parameters
         (options, args) = usrp_siggen.get_options()
@@ -308,3 +308,10 @@ if __name__ == "__main__":
     except RuntimeError, e:
         print e
         sys.exit(1)
+
+# Make sure to create the top block (tb) within a function:
+# That code in main will allow tb to go out of scope on return,
+# which will call the decontructor on usrp and stop transmit.
+# Whats odd is that grc works fine with tb in the __main__,
+# perhaps its because the try/except clauses around tb.
+if __name__ == "__main__": main()