changeset 758:5b6655449ba6

Refuse to nest OSC invocations
author Chris Cannam
date Wed, 29 Apr 2020 15:27:13 +0100
parents e7c77c366360
children 5f8fc01e01c7
files framework/MainWindowBase.cpp framework/MainWindowBase.h
diffstat 2 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Wed Apr 22 17:10:52 2020 +0100
+++ b/framework/MainWindowBase.cpp	Wed Apr 29 15:27:13 2020 +0100
@@ -160,6 +160,7 @@
     m_recentTransforms("RecentTransforms", 20),
     m_documentModified(false),
     m_openingAudioFile(false),
+    m_handlingOSC(false),
     m_labeller(nullptr),
     m_lastPlayStatusSec(0),
     m_initialDarkBackground(false),
@@ -1565,10 +1566,10 @@
         }
     }
 
+    m_openingAudioFile = true;
+
     source.waitForData();
 
-    m_openingAudioFile = true;
-
     sv_samplerate_t rate = 0;
 
     SVDEBUG << "Checking whether to preserve incoming audio file's sample rate"
@@ -4279,12 +4280,22 @@
 {
     if (!m_oscQueue || m_oscQueue->isEmpty()) return;
 
+    if (m_handlingOSC) {
+        SVDEBUG << "MainWindowBase::pollOSC: "
+                << "not making nested invocations, waiting"
+                << endl;
+        return;
+    }
+    
+    m_handlingOSC = true;
+
     while (!m_oscQueue->isEmpty()) {
 
         if (m_openingAudioFile) {
             SVDEBUG << "MainWindowBase::pollOSC: "
                     << "waiting for audio to finish loading"
                     << endl;
+            m_handlingOSC = false;
             return;
         }
 
@@ -4292,6 +4303,7 @@
             SVDEBUG << "MainWindowBase::pollOSC: "
                     << "waiting for running transforms to complete"
                     << endl;
+            m_handlingOSC = false;
             return;
         }
 
@@ -4304,6 +4316,7 @@
         if (message.getTarget() != 0) {
             SVCERR << "MainWindowBase::pollOSC: ignoring message with target "
                    << message.getTarget() << " (we are target 0)" << endl;
+            m_handlingOSC = false;
             continue;
         }
 
@@ -4314,10 +4327,12 @@
         
         QApplication::processEvents(QEventLoop::ExcludeUserInputEvents |
                                     QEventLoop::ExcludeSocketNotifiers);
-
-        connect(m_oscQueue, SIGNAL(messagesAvailable()),
-                this, SLOT(pollOSC()));
     }
+
+    m_handlingOSC = false;
+
+    connect(m_oscQueue, SIGNAL(messagesAvailable()),
+            this, SLOT(pollOSC()));
 }
 
 void
--- a/framework/MainWindowBase.h	Wed Apr 22 17:10:52 2020 +0100
+++ b/framework/MainWindowBase.h	Wed Apr 29 15:27:13 2020 +0100
@@ -449,6 +449,7 @@
 
     bool                     m_documentModified;
     bool                     m_openingAudioFile;
+    bool                     m_handlingOSC;
 
     Labeller                *m_labeller;