UI: HostInfoCache: Abort lookups on exit.

This commit is contained in:
Nodir Temirkhodjaev 2021-05-28 12:35:20 +03:00
parent b65e76eba2
commit 2bd992bd12
4 changed files with 17 additions and 3 deletions

View File

@ -11,6 +11,12 @@ HostInfoCache::HostInfoCache(QObject *parent) :
connect(&m_triggerTimer, &QTimer::timeout, this, &HostInfoCache::cacheChanged);
}
HostInfoCache::~HostInfoCache()
{
clear();
abort();
}
QString HostInfoCache::hostName(const QString &address)
{
HostInfo *hostInfo = m_cache.object(address);
@ -33,6 +39,11 @@ void HostInfoCache::clear()
emitCacheChanged();
}
void HostInfoCache::abort()
{
m_manager->abort();
}
void HostInfoCache::handleFinishedLookup(const QString &address, const QString &hostName)
{
HostInfo *hostInfo = m_cache.object(address);

View File

@ -15,6 +15,7 @@ class HostInfoCache : public QObject
public:
explicit HostInfoCache(QObject *parent = nullptr);
~HostInfoCache() override;
signals:
void cacheChanged();
@ -23,6 +24,7 @@ public slots:
QString hostName(const QString &address);
void clear();
void abort();
private slots:
void handleFinishedLookup(const QString &address, const QString &hostName);

View File

@ -12,6 +12,7 @@ WorkerManager::WorkerManager(QObject *parent) : QObject(parent) { }
WorkerManager::~WorkerManager()
{
clear();
abort();
}

View File

@ -22,6 +22,8 @@ public:
~WorkerManager() override;
CLASS_DELETE_COPY_MOVE(WorkerManager)
bool aborted() const { return m_aborted; }
int maxWorkersCount() const { return m_maxWorkersCount; }
void setMaxWorkersCount(int v) { m_maxWorkersCount = v; }
@ -29,6 +31,7 @@ signals:
public slots:
void clear();
void abort();
void enqueueJob(WorkerJob *job);
WorkerJob *dequeueJob();
@ -40,9 +43,6 @@ public slots:
protected:
virtual WorkerObject *createWorker();
bool aborted() const { return m_aborted; }
void abort();
private:
void setupWorker();