From f11c3a1b582b1dc7021663d162f73dbfb040d82f Mon Sep 17 00:00:00 2001 From: "Simon A. Eugster" Date: Sun, 5 Dec 2010 21:08:04 +0000 Subject: [PATCH] Using #ifdef for debugging instead of commenting out in Abstract Scopes svn path=/trunk/kdenlive/; revision=5136 --- src/abstractscopewidget.cpp | 93 +++++++++++++++----- src/audioscopes/abstractaudioscopewidget.cpp | 1 - src/colorscopes/abstractgfxscopewidget.cpp | 16 +++- 3 files changed, 86 insertions(+), 24 deletions(-) diff --git a/src/abstractscopewidget.cpp b/src/abstractscopewidget.cpp index 8b42676f..86f1cb59 100644 --- a/src/abstractscopewidget.cpp +++ b/src/abstractscopewidget.cpp @@ -20,6 +20,13 @@ #include #include +// Uncomment for Scope debugging. +//#define DEBUG_ASW + +#ifdef DEBUG_ASW +#include +#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 diff --git a/src/audioscopes/abstractaudioscopewidget.cpp b/src/audioscopes/abstractaudioscopewidget.cpp index 5f14fd2e..71a6263c 100644 --- a/src/audioscopes/abstractaudioscopewidget.cpp +++ b/src/audioscopes/abstractaudioscopewidget.cpp @@ -14,7 +14,6 @@ #include "renderer.h" #include "monitor.h" -#include #include #include #include diff --git a/src/colorscopes/abstractgfxscopewidget.cpp b/src/colorscopes/abstractgfxscopewidget.cpp index 232eb261..275be135 100644 --- a/src/colorscopes/abstractgfxscopewidget.cpp +++ b/src/colorscopes/abstractgfxscopewidget.cpp @@ -20,6 +20,13 @@ #include #include +// Uncomment for debugging. +//#define DEBUG_AGSW + +#ifdef DEBUG_AGSW +#include +#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 -- 2.39.2