glvdebug: Minor clean up of the connection types between the ReplayWorker and the...
authorPeter Lohrmann <peterl@valvesoftware.com>
Fri, 27 Feb 2015 17:30:35 +0000 (09:30 -0800)
committerPeter Lohrmann <peterl@valvesoftware.com>
Fri, 27 Feb 2015 17:30:35 +0000 (09:30 -0800)
tools/glave/src/glv_extensions/glvdebug_xgl/glvdebug_xgl_qcontroller.cpp
tools/glave/src/glvdebug/glvdebug_QReplayWidget.h
tools/glave/src/glvdebug/glvdebug_QReplayWorker.cpp
tools/glave/src/glvdebug/glvdebug_QReplayWorker.h

index a6c48aa..d2a1611 100644 (file)
@@ -91,15 +91,15 @@ bool glvdebug_xgl_QController::LoadTraceFile(glvdebug_trace_file_info* pTraceFil
         {
             m_pView->add_custom_state_viewer(m_pReplayWidget, "Replayer", true);
             m_pReplayWidget->setEnabled(true);
-            connect(m_pReplayWidget, SIGNAL(ReplayStarted()), this, SLOT(onReplayStarted()), Qt::QueuedConnection);
-            connect(m_pReplayWidget, SIGNAL(ReplayPaused(uint64_t)), this, SLOT(onReplayPaused(uint64_t)), Qt::QueuedConnection);
-            connect(m_pReplayWidget, SIGNAL(ReplayContinued()), this, SLOT(onReplayContinued()), Qt::QueuedConnection);
-            connect(m_pReplayWidget, SIGNAL(ReplayStopped(uint64_t)), this, SLOT(onReplayStopped(uint64_t)), Qt::QueuedConnection);
-            connect(m_pReplayWidget, SIGNAL(ReplayFinished(uint64_t)), this, SLOT(onReplayFinished(uint64_t)), Qt::QueuedConnection);
-
-            connect(m_pReplayWidget, SIGNAL(OutputMessage(const QString&)), this, SLOT(OnOutputMessage(const QString&)), Qt::QueuedConnection);
-            connect(m_pReplayWidget, SIGNAL(OutputError(const QString&)), this, SLOT(OnOutputError(const QString&)), Qt::QueuedConnection);
-            connect(m_pReplayWidget, SIGNAL(OutputWarning(const QString&)), this, SLOT(OnOutputWarning(const QString&)), Qt::QueuedConnection);
+            connect(m_pReplayWidget, SIGNAL(ReplayStarted()), this, SLOT(onReplayStarted()));
+            connect(m_pReplayWidget, SIGNAL(ReplayPaused(uint64_t)), this, SLOT(onReplayPaused(uint64_t)));
+            connect(m_pReplayWidget, SIGNAL(ReplayContinued()), this, SLOT(onReplayContinued()));
+            connect(m_pReplayWidget, SIGNAL(ReplayStopped(uint64_t)), this, SLOT(onReplayStopped(uint64_t)));
+            connect(m_pReplayWidget, SIGNAL(ReplayFinished(uint64_t)), this, SLOT(onReplayFinished(uint64_t)));
+
+            connect(m_pReplayWidget, SIGNAL(OutputMessage(const QString&)), this, SLOT(OnOutputMessage(const QString&)));
+            connect(m_pReplayWidget, SIGNAL(OutputError(const QString&)), this, SLOT(OnOutputError(const QString&)));
+            connect(m_pReplayWidget, SIGNAL(OutputWarning(const QString&)), this, SLOT(OnOutputWarning(const QString&)));
         }
     }
 
index fafffa5..0584041 100755 (executable)
@@ -87,29 +87,32 @@ public:
         m_pReplayWindow = new QWidget(this);\r
         pLayout->addWidget(m_pReplayWindow);\r
 \r
-        connect(this, SIGNAL(PlayButtonClicked()), m_pWorker, SLOT(StartReplay()), Qt::QueuedConnection);\r
-        connect(this, SIGNAL(StepButtonClicked()), m_pWorker, SLOT(StepReplay()), Qt::DirectConnection);\r
-        connect(this, SIGNAL(PauseButtonClicked()), m_pWorker, SLOT(PauseReplay()), Qt::DirectConnection);\r
-        connect(this, SIGNAL(ContinueButtonClicked()), m_pWorker, SLOT(ContinueReplay()), Qt::QueuedConnection);\r
-        connect(this, SIGNAL(StopButtonClicked()), m_pWorker, SLOT(StopReplay()), Qt::DirectConnection);\r
-        connect(this, SIGNAL(DetachCheckBoxClicked(bool)), m_pWorker, SLOT(DetachReplay(bool)));\r
-\r
-\r
         // connect worker signals to widget actions\r
         qRegisterMetaType<uint64_t>("uint64_t");\r
         m_replayThread.setObjectName("ReplayThread");\r
         m_pWorker->moveToThread(&m_replayThread);\r
         m_replayThread.start();\r
 \r
+        // Clicking the Pause and Stop buttons are direct connections so that they happen more immediately than a queued connection.\r
+        // Queued connections are used here whenever the replay will be advanced from a stopped state,\r
+        // and for all the signals FROM the worker object since it is on a different thread.\r
+        connect(this, SIGNAL(PlayButtonClicked()), m_pWorker, SLOT(StartReplay()), Qt::QueuedConnection);\r
+        connect(this, SIGNAL(StepButtonClicked()), m_pWorker, SLOT(StepReplay()), Qt::QueuedConnection);\r
+        connect(this, SIGNAL(PauseButtonClicked()), m_pWorker, SLOT(PauseReplay()), Qt::DirectConnection);\r
+        connect(this, SIGNAL(ContinueButtonClicked()), m_pWorker, SLOT(ContinueReplay()), Qt::QueuedConnection);\r
+        connect(this, SIGNAL(StopButtonClicked()), m_pWorker, SLOT(StopReplay()), Qt::DirectConnection);\r
+        connect(this, SIGNAL(DetachCheckBoxClicked(bool)), m_pWorker, SLOT(DetachReplay(bool)), Qt::QueuedConnection);\r
+\r
         connect(m_pWorker, SIGNAL(ReplayStarted()), this, SLOT(slotReplayStarted()), Qt::QueuedConnection);\r
         connect(m_pWorker, SIGNAL(ReplayPaused(uint64_t)), this, SLOT(slotReplayPaused(uint64_t)), Qt::QueuedConnection);\r
         connect(m_pWorker, SIGNAL(ReplayContinued()), this, SLOT(slotReplayContinued()), Qt::QueuedConnection);\r
         connect(m_pWorker, SIGNAL(ReplayStopped(uint64_t)), this, SLOT(slotReplayStopped(uint64_t)), Qt::QueuedConnection);\r
         connect(m_pWorker, SIGNAL(ReplayFinished(uint64_t)), this, SLOT(slotReplayFinished(uint64_t)), Qt::QueuedConnection);\r
 \r
-        connect(m_pWorker, SIGNAL(OutputMessage(const QString&)), this, SLOT(OnOutputMessage(const QString&)), Qt::BlockingQueuedConnection);\r
-        connect(m_pWorker, SIGNAL(OutputError(const QString&)), this, SLOT(OnOutputError(const QString&)), Qt::BlockingQueuedConnection);\r
-        connect(m_pWorker, SIGNAL(OutputWarning(const QString&)), this, SLOT(OnOutputWarning(const QString&)), Qt::BlockingQueuedConnection);\r
+        connect(m_pWorker, SIGNAL(OutputMessage(const QString&)), this, SLOT(OnOutputMessage(const QString&)), Qt::QueuedConnection);\r
+        connect(m_pWorker, SIGNAL(OutputError(const QString&)), this, SLOT(OnOutputError(const QString&)), Qt::QueuedConnection);\r
+        connect(m_pWorker, SIGNAL(OutputWarning(const QString&)), this, SLOT(OnOutputWarning(const QString&)), Qt::QueuedConnection);\r
+\r
     }\r
 \r
     virtual ~glvdebug_QReplayWidget()\r
index 4b90390..1a412ec 100644 (file)
@@ -316,7 +316,6 @@ void glvdebug_QReplayWorker::playCurrentTraceFile(uint64_t startPacketIndex)
         }
 
         // Process events and pause or stop if needed
-        QCoreApplication::sendPostedEvents();
         if (m_bPauseReplay || m_pauseAtPacketIndex == m_currentReplayPacketIndex)
         {
             if (m_pauseAtPacketIndex == m_currentReplayPacketIndex)
index d1dc5bc..d6858dc 100644 (file)
@@ -84,8 +84,8 @@ signals:
     void OutputWarning(const QString& msg);
 
 private:
-    bool m_bPauseReplay;
-    bool m_bStopReplay;
+    volatile bool m_bPauseReplay;
+    volatile bool m_bStopReplay;
     glvdebug_view* m_pView;
     glvdebug_trace_file_info* m_pTraceFileInfo;
     uint64_t m_currentReplayPacketIndex;