From d5a3c74043e2c4295d2ba054d289c479998d9a4e Mon Sep 17 00:00:00 2001 From: David Sansome Date: Tue, 27 Apr 2010 21:40:28 +0000 Subject: [PATCH] Make analyzers use QBasicTimer instead of QTimer --- src/analyzers/analyzerbase.cpp | 10 ++++++++-- src/analyzers/analyzerbase.h | 15 +++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/analyzers/analyzerbase.cpp b/src/analyzers/analyzerbase.cpp index 2da5c81e3..dc1faa0a4 100644 --- a/src/analyzers/analyzerbase.cpp +++ b/src/analyzers/analyzerbase.cpp @@ -49,7 +49,6 @@ Analyzer::Base::Base( QWidget *parent, uint scopeSize ) , m_engine(NULL) , m_lastScope(512) { - connect( &m_timer, SIGNAL( timeout() ), SLOT( update() ) ); } void Analyzer::Base::hideEvent(QHideEvent *) { @@ -57,7 +56,7 @@ void Analyzer::Base::hideEvent(QHideEvent *) { } void Analyzer::Base::showEvent(QShowEvent *) { - m_timer.start(timeout()); + m_timer.start(timeout(), this); } void Analyzer::Base::transform( Scope &scope ) //virtual @@ -217,3 +216,10 @@ Analyzer::initSin( Scope &v, const uint size ) //static radian += step; } } + +void Analyzer::Base::timerEvent(QTimerEvent* e) { + if (e->timerId() != m_timer.timerId()) + return; + + update(); +} diff --git a/src/analyzers/analyzerbase.h b/src/analyzers/analyzerbase.h index 40ebdcb4c..c30d433fb 100644 --- a/src/analyzers/analyzerbase.h +++ b/src/analyzers/analyzerbase.h @@ -12,7 +12,7 @@ #include "engines/engine_fwd.h" #include "fht.h" //stack allocated and convenience #include //stack allocated and convenience -#include //stack allocated +#include //stack allocated #include //baseclass #include //included for convenience @@ -51,6 +51,7 @@ protected: void hideEvent(QHideEvent *); void showEvent(QShowEvent *); void paintEvent( QPaintEvent* ); + void timerEvent(QTimerEvent *); void polishEvent(); @@ -62,14 +63,16 @@ protected: virtual void paused(QPainter& p); virtual void demo(QPainter& p); - void changeTimeout( uint newTimeout ) - { - m_timer.setInterval( newTimeout ); - m_timeout = newTimeout; + void changeTimeout( uint newTimeout ) { + m_timeout = newTimeout; + if (m_timer.isActive()) { + m_timer.stop(); + m_timer.start(m_timeout, this); + } } protected: - QTimer m_timer; + QBasicTimer m_timer; uint m_timeout; FHT *m_fht; EngineBase* m_engine;