mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 15:45:42 +08:00
Used timer no longer pointer
This commit is contained in:
committed by
Mathew Sutcliffe
parent
d7ae3712dd
commit
595c71b387
@@ -32,11 +32,10 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
CThreadedReader::CThreadedReader(QObject *owner, const QString &name) :
|
CThreadedReader::CThreadedReader(QObject *owner, const QString &name) :
|
||||||
CContinuousWorker(owner, name),
|
CContinuousWorker(owner, name)
|
||||||
m_updateTimer(new QTimer(this))
|
|
||||||
{
|
{
|
||||||
connect(m_updateTimer, &QTimer::timeout, this, &CThreadedReader::doWork);
|
connect(&m_updateTimer, &QTimer::timeout, this, &CThreadedReader::doWork);
|
||||||
m_updateTimer->setSingleShot(true);
|
m_updateTimer.setSingleShot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CThreadedReader::~CThreadedReader()
|
CThreadedReader::~CThreadedReader()
|
||||||
@@ -77,6 +76,7 @@ namespace BlackCore
|
|||||||
void CThreadedReader::gracefulShutdown()
|
void CThreadedReader::gracefulShutdown()
|
||||||
{
|
{
|
||||||
// if not in main thread stop, otherwise it makes no sense to abandon
|
// if not in main thread stop, otherwise it makes no sense to abandon
|
||||||
|
if (this->m_shutdown) { return; }
|
||||||
this->m_shutdown = true;
|
this->m_shutdown = true;
|
||||||
if (!CThreadUtils::isCurrentThreadObjectThread(this))
|
if (!CThreadUtils::isCurrentThreadObjectThread(this))
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CThreadedReader::pauseReader()
|
void CThreadedReader::pauseReader()
|
||||||
{
|
{
|
||||||
QTimer::singleShot(0, m_updateTimer, &QTimer::stop);
|
QTimer::singleShot(0, &m_updateTimer, &QTimer::stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CThreadedReader::isShuttingDown() const
|
bool CThreadedReader::isShuttingDown() const
|
||||||
@@ -139,11 +139,11 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
m_initialTime = initialTime;
|
m_initialTime = initialTime;
|
||||||
m_periodicTime = periodicTime;
|
m_periodicTime = periodicTime;
|
||||||
if (m_updateTimer->isActive())
|
if (m_updateTimer.isActive())
|
||||||
{
|
{
|
||||||
int oldPeriodicTime = m_updateTimer->interval();
|
int oldPeriodicTime = m_updateTimer.interval();
|
||||||
int delta = m_periodicTime - oldPeriodicTime + m_updateTimer->remainingTime();
|
int delta = m_periodicTime - oldPeriodicTime + m_updateTimer.remainingTime();
|
||||||
m_updateTimer->start(qMax(delta, 0));
|
m_updateTimer.start(qMax(delta, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ namespace BlackCore
|
|||||||
if (isFinished()) { return; }
|
if (isFinished()) { return; }
|
||||||
doWorkImpl();
|
doWorkImpl();
|
||||||
Q_ASSERT(m_periodicTime > 0);
|
Q_ASSERT(m_periodicTime > 0);
|
||||||
m_updateTimer->start(m_periodicTime);
|
m_updateTimer.start(m_periodicTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ namespace BlackCore
|
|||||||
uint m_contentHash = 0; //!< has of the content given
|
uint m_contentHash = 0; //!< has of the content given
|
||||||
std::atomic<bool> m_markedAsFailed { false }; //!< marker if reading failed
|
std::atomic<bool> m_markedAsFailed { false }; //!< marker if reading failed
|
||||||
std::atomic<bool> m_shutdown { false }; //!< marker it is shutting down
|
std::atomic<bool> m_shutdown { false }; //!< marker it is shutting down
|
||||||
QTimer *m_updateTimer = nullptr;
|
QTimer m_updateTimer { this };
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user