From 5b8f4f3e92d662f36580b94184057b648be9f01d Mon Sep 17 00:00:00 2001 From: Koncord Date: Fri, 5 Jan 2018 08:38:29 +0800 Subject: [PATCH] [Browser] Stop PingHelper on refresh --- apps/browser/PingHelper.cpp | 6 ++++++ apps/browser/PingHelper.hpp | 1 + apps/browser/PingUpdater.cpp | 2 +- apps/browser/QueryHelper.cpp | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/browser/PingHelper.cpp b/apps/browser/PingHelper.cpp index 030f71610..b5f946b8a 100644 --- a/apps/browser/PingHelper.cpp +++ b/apps/browser/PingHelper.cpp @@ -14,6 +14,12 @@ void PingHelper::Add(int row, const AddrPair &addrPair) pingThread->start(); } +void PingHelper::Reset() +{ + //if (pingThread->isRunning()) + Stop(); +} + void PingHelper::Stop() { emit pingUpdater->stop(); diff --git a/apps/browser/PingHelper.hpp b/apps/browser/PingHelper.hpp index 7866d7bfc..808757482 100644 --- a/apps/browser/PingHelper.hpp +++ b/apps/browser/PingHelper.hpp @@ -17,6 +17,7 @@ class PingHelper : public QObject Q_OBJECT public: + void Reset(); void Add(int row, const AddrPair &addrPair); void Stop(); void SetModel(QAbstractTableModel *model); diff --git a/apps/browser/PingUpdater.cpp b/apps/browser/PingUpdater.cpp index 54122ffd8..befea9c3c 100644 --- a/apps/browser/PingUpdater.cpp +++ b/apps/browser/PingUpdater.cpp @@ -42,7 +42,7 @@ void PingUpdater::process() unsigned ping = PingRakNetServer(server.second.first.toLatin1(), server.second.second); qDebug() << "Pong from" << server.second.first + "|" + QString::number(server.second.second) - << ":" << ping << "ms"; + << ":" << ping << "ms" << "Sizeof servers: " << servers.size(); emit updateModel(server.first, ping); } diff --git a/apps/browser/QueryHelper.cpp b/apps/browser/QueryHelper.cpp index 2e1be8df2..8fee88db8 100644 --- a/apps/browser/QueryHelper.cpp +++ b/apps/browser/QueryHelper.cpp @@ -29,6 +29,7 @@ void QueryHelper::refresh() if (!queryThread->isRunning()) { _model->removeRows(0, _model->rowCount()); + PingHelper::Get().Stop(); queryThread->start(); emit started(); }