添加析构函数

This commit is contained in:
2021-12-28 11:02:06 +08:00
parent 0cf5f8a281
commit 3ced20152d
2 changed files with 7 additions and 2 deletions

View File

@@ -12,6 +12,10 @@ RateSeveral::RateSeveral(QObject *parent) :
connect(&timer, SIGNAL(timeout()), this, SLOT(onTimerTimeout())); connect(&timer, SIGNAL(timeout()), this, SLOT(onTimerTimeout()));
} }
RateSeveral::~RateSeveral() {
timer.stop();
}
void RateSeveral::setTimerInterval(qint32 second) { void RateSeveral::setTimerInterval(qint32 second) {
timer.start(second * 1000); timer.start(second * 1000);
} }
@@ -44,7 +48,6 @@ void RateSeveral::record(quint32 val) {
recordList.last().second.fetchAndAddAcquire(val); recordList.last().second.fetchAndAddAcquire(val);
} }
void RateSeveral::onTimerTimeout() { void RateSeveral::onTimerTimeout() {
intervalLock.lockForRead(); intervalLock.lockForRead();
auto interval = vInterval; auto interval = vInterval;

View File

@@ -18,6 +18,8 @@ Q_OBJECT
public: public:
explicit RateSeveral(QObject *parent = nullptr); explicit RateSeveral(QObject *parent = nullptr);
virtual ~RateSeveral();
void setTimerInterval(qint32 second); void setTimerInterval(qint32 second);
void addRateInterval(quint32 second); void addRateInterval(quint32 second);
@@ -30,8 +32,8 @@ public:
void setMaxListSize(quint32 maxSize); void setMaxListSize(quint32 maxSize);
signals:
signals:
void RateSignals(quint32 interval, quint32 rate); void RateSignals(quint32 interval, quint32 rate);
protected slots: protected slots: