g4ixt / QtTinySA

A Python 'TinySA' GUI programme using Qt5 and PyQt5
GNU General Public License v3.0
107 stars 26 forks source link

Stopping a slow scan freezes the trace until the scan is finished #8

Closed Ho-Ro closed 1 year ago

Ho-Ro commented 1 year ago

The event processing is blocked during this while loop

        while tinySA.threadrunning:
            time.sleep(0.1)  # wait until the measurement thread stops using the serial comms

The solution is to continue processing the events while waiting for the thread to finish, this gives visual feedback of the pending time:

diff --git a/QtTinySA.py b/QtTinySA.py
index 033900c..c5342e4 100644
--- a/QtTinySA.py
+++ b/QtTinySA.py
@@ -360,6 +360,7 @@ def scan():
         tinySA.sweeping = False  # tells the measurement thread to stop once current scan complete
         ui.scan_button.setEnabled(False)  # prevent repeat presses of 'stop'
         while tinySA.threadrunning:
+            app.processEvents()
             time.sleep(0.1)  # wait until the measurement thread stops using the serial comms
         ui.scan_button.setEnabled(True)
         activeButtons(True)
g4ixt commented 1 year ago

I had noticed this behaviour but hadn't realised why. Your solution included in code.