]> git.sesse.net Git - kdenlive/commitdiff
Using #ifdef for debugging instead of commenting out in Abstract Scopes
authorSimon A. Eugster <simon.eu@gmail.com>
Sun, 5 Dec 2010 21:08:04 +0000 (21:08 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Sun, 5 Dec 2010 21:08:04 +0000 (21:08 +0000)
svn path=/trunk/kdenlive/; revision=5136

src/abstractscopewidget.cpp
src/audioscopes/abstractaudioscopewidget.cpp
src/colorscopes/abstractgfxscopewidget.cpp

index 8b42676fa0f8654c4bb6dab4bc5ea100e0d13066..86f1cb595b5fcb15bbc426259d035850dda9070e 100644 (file)
 #include <QMouseEvent>
 #include <QPainter>
 
+// Uncomment for Scope debugging.
+//#define DEBUG_ASW
+
+#ifdef DEBUG_ASW
+#include <QDebug>
+#endif
+
 const int REALTIME_FPS = 30;
 
 const QColor light(250, 238, 226, 255);
@@ -127,7 +134,9 @@ QString AbstractScopeWidget::configName()
 void AbstractScopeWidget::prodHUDThread()
 {
     if (this->visibleRegion().isEmpty()) {
-//        qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating HUD.";
+#ifdef DEBUG_ASW
+        qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating HUD.";
+#endif
     } else {
         if (m_semaphoreHUD.tryAcquire(1)) {
             Q_ASSERT(!m_threadHUD.isRunning());
@@ -135,11 +144,16 @@ void AbstractScopeWidget::prodHUDThread()
             m_newHUDFrames.fetchAndStoreRelaxed(0);
             m_newHUDUpdates.fetchAndStoreRelaxed(0);
             m_threadHUD = QtConcurrent::run(this, &AbstractScopeWidget::renderHUD, m_accelFactorHUD);
-//            qDebug() << "HUD thread started in " << m_widgetName;
+#ifdef DEBUG_ASW
+            qDebug() << "HUD thread started in " << m_widgetName;
+#endif
 
-        } else {
-//            qDebug() << "HUD semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadHUD.isRunning();
         }
+#ifdef DEBUG_ASW
+        else {
+            qDebug() << "HUD semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadHUD.isRunning();
+        }
+#endif
     }
 }
 
@@ -148,7 +162,9 @@ void AbstractScopeWidget::prodScopeThread()
     // Only start a new thread if the scope is actually visible
     // and not hidden by another widget on the stack and if user want the scope to update.
     if (this->visibleRegion().isEmpty() || (!m_aAutoRefresh->isChecked() && !m_requestForcedUpdate)) {
-//        qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating scope.";
+#ifdef DEBUG_ASW
+        qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating scope.";
+#endif
     } else {
         // Try to acquire the semaphore. This must only succeed if m_threadScope is not running
         // anymore. Therefore the semaphore must NOT be released before m_threadScope ends.
@@ -166,17 +182,23 @@ void AbstractScopeWidget::prodScopeThread()
             m_threadScope = QtConcurrent::run(this, &AbstractScopeWidget::renderScope, m_accelFactorScope);
             m_requestForcedUpdate = false;
 
-//            qDebug() << "Scope thread started in " << m_widgetName;
+#ifdef DEBUG_ASW
+            qDebug() << "Scope thread started in " << m_widgetName;
+#endif
 
         } else {
-//            qDebug() << "Scope semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadScope.isRunning();
+#ifdef DEBUG_ASW
+            qDebug() << "Scope semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadScope.isRunning();
+#endif
         }
     }
 }
 void AbstractScopeWidget::prodBackgroundThread()
 {
     if (this->visibleRegion().isEmpty()) {
-//        qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating background.";
+#ifdef DEBUG_ASW
+        qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating background.";
+#endif
     } else {
         if (m_semaphoreBackground.tryAcquire(1)) {
             Q_ASSERT(!m_threadBackground.isRunning());
@@ -184,17 +206,25 @@ void AbstractScopeWidget::prodBackgroundThread()
             m_newBackgroundFrames.fetchAndStoreRelaxed(0);
             m_newBackgroundUpdates.fetchAndStoreRelaxed(0);
             m_threadBackground = QtConcurrent::run(this, &AbstractScopeWidget::renderBackground, m_accelFactorBackground);
-//            qDebug() << "Background thread started in " << m_widgetName;
+
+#ifdef DEBUG_ASW
+            qDebug() << "Background thread started in " << m_widgetName;
+#endif
 
         } else {
-//            qDebug() << "Background semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadBackground.isRunning();
+#ifdef DEBUG_ASW
+            qDebug() << "Background semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadBackground.isRunning();
+#endif
         }
     }
 }
 
 void AbstractScopeWidget::forceUpdate(bool doUpdate)
 {
-//    qDebug() << "Force update called in " << widgetName() << ". Arg: " << doUpdate;
+#ifdef DEBUG_ASW
+    qDebug() << "Force update called in " << widgetName() << ". Arg: " << doUpdate;
+#endif
+
     if (!doUpdate) {
         return;
     }
@@ -315,8 +345,10 @@ void AbstractScopeWidget::slotHUDRenderingFinished(uint mseconds, uint oldFactor
     }
 
     if ((m_newHUDFrames > 0 && m_aAutoRefresh->isChecked()) || m_newHUDUpdates > 0) {
-//        qDebug() << "Trying to start a new HUD thread for " << m_widgetName
-//                << ". New frames/updates: " << m_newHUDFrames << "/" << m_newHUDUpdates;
+#ifdef DEBUG_ASW
+        qDebug() << "Trying to start a new HUD thread for " << m_widgetName
+                << ". New frames/updates: " << m_newHUDFrames << "/" << m_newHUDUpdates;
+#endif
         prodHUDThread();;
     }
 }
@@ -325,7 +357,9 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact
 {
     // The signal can be received before the thread has really finished. So we
     // need to wait until it has really finished before starting a new thread.
-//    qDebug() << "Scope rendering has finished, waiting for termination in " << m_widgetName;
+#ifdef DEBUG_ASW
+    qDebug() << "Scope rendering has finished, waiting for termination in " << m_widgetName;
+#endif
     m_threadScope.waitForFinished();
     m_imgScope = m_threadScope.result();
 
@@ -349,15 +383,19 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact
     }
 
     if ((m_newScopeFrames > 0 && m_aAutoRefresh->isChecked()) || m_newScopeUpdates > 0) {
-//        qDebug() << "Trying to start a new scope thread for " << m_widgetName
-//                << ". New frames/updates: " << m_newScopeFrames << "/" << m_newScopeUpdates;
+#ifdef DEBUG_ASW
+        qDebug() << "Trying to start a new scope thread for " << m_widgetName
+                << ". New frames/updates: " << m_newScopeFrames << "/" << m_newScopeUpdates;
+#endif
         prodScopeThread();
     }
 }
 
 void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint oldFactor)
 {
-//    qDebug() << "Background rendering has finished, waiting for termination in " << m_widgetName;
+#ifdef DEBUG_ASW
+    qDebug() << "Background rendering has finished, waiting for termination in " << m_widgetName;
+#endif
     m_threadBackground.waitForFinished();
     m_imgBackground = m_threadBackground.result();
 
@@ -374,8 +412,10 @@ void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint ol
     }
 
     if ((m_newBackgroundFrames > 0 && m_aAutoRefresh->isChecked()) || m_newBackgroundUpdates > 0) {
-//        qDebug() << "Trying to start a new background thread for " << m_widgetName
-//                << ". New frames/updates: " << m_newBackgroundFrames << "/" << m_newBackgroundUpdates;
+#ifdef DEBUG_ASW
+        qDebug() << "Trying to start a new background thread for " << m_widgetName
+                << ". New frames/updates: " << m_newBackgroundFrames << "/" << m_newBackgroundUpdates;
+#endif
         prodBackgroundThread();;
     }
 }
@@ -386,11 +426,15 @@ void AbstractScopeWidget::slotRenderZoneUpdated()
     m_newScopeFrames.fetchAndAddRelaxed(1);
     m_newBackgroundFrames.fetchAndAddRelaxed(1);
 
-//    qDebug() << "Monitor incoming. New frames total HUD/Scope/Background: " << m_newHUDFrames
-//            << "/" << m_newScopeFrames << "/" << m_newBackgroundFrames;
+#ifdef DEBUG_ASW
+    qDebug() << "Monitor incoming. New frames total HUD/Scope/Background: " << m_newHUDFrames
+            << "/" << m_newScopeFrames << "/" << m_newBackgroundFrames;
+#endif
 
     if (this->visibleRegion().isEmpty()) {
-//        qDebug() << "Scope of widget " << m_widgetName << " is not at the top, not rendering.";
+#ifdef DEBUG_ASW
+        qDebug() << "Scope of widget " << m_widgetName << " is not at the top, not rendering.";
+#endif
     } else {
         if (m_aAutoRefresh->isChecked()) {
             prodHUDThread();
@@ -431,3 +475,8 @@ void AbstractScopeWidget::slotAutoRefreshToggled(bool autoRefresh)
         m_requestForcedUpdate = true;
     }
 }
+
+
+#ifdef DEBUG_ASW
+#undef DEBUG_ASW
+#endif
index 5f14fd2ee3124aa995234b81745a4c2dd7c408ca..71a6263c7b8c789f90ace89d33c5a317478340d5 100644 (file)
@@ -14,7 +14,6 @@
 #include "renderer.h"
 #include "monitor.h"
 
-#include <QDebug>
 #include <QFuture>
 #include <QColor>
 #include <QMenu>
index 232eb2618fea9ad2d023723b03ed17fb8a936352..275be135610540a8132f086e442a0bdcf17be4d9 100644 (file)
 #include <QMouseEvent>
 #include <QPainter>
 
+// Uncomment for debugging.
+//#define DEBUG_AGSW
+
+#ifdef DEBUG_AGSW
+#include <QDebug>
+#endif
+
 const int REALTIME_FPS = 30;
 
 AbstractGfxScopeWidget::AbstractGfxScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse, QWidget *parent) :
@@ -54,7 +61,9 @@ void AbstractGfxScopeWidget::mouseReleaseEvent(QMouseEvent *event)
 
 void AbstractGfxScopeWidget::slotActiveMonitorChanged(bool isClipMonitor)
 {
-//    qDebug() << "Active monitor has changed in " << m_widgetName << ". Is the clip monitor active now? " << isClipMonitor;
+#ifdef DEBUG_AGSW
+    qDebug() << "Active monitor has changed in " << widgetName() << ". Is the clip monitor active now? " << isClipMonitor;
+#endif
 
     bool b = m_activeRender->disconnect(this);
     Q_ASSERT(b);
@@ -81,3 +90,8 @@ void AbstractGfxScopeWidget::slotAutoRefreshToggled(bool autoRefresh)
         m_activeRender->sendFrameUpdate();
     }
 }
+
+
+#ifdef DEBUG_AGSW
+#undef DEBUG_AGSW
+#endif