tdf#43157 - salhelper: timer.cxx change OSL_ASSERT to assert
There are a number of instances where OSL_ASSERT are just not necessary. Also, we need to change from testing if something is/is not equal to nullptr and just use the simpler form. Change-Id: I7e0b7deb12f0189030f66dd14ab23287341c82b7 Reviewed-on: https://gerrit.libreoffice.org/38507 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
This commit is contained in:
@@ -19,7 +19,6 @@
|
|||||||
#include <salhelper/timer.hxx>
|
#include <salhelper/timer.hxx>
|
||||||
#include <salhelper/simplereferenceobject.hxx>
|
#include <salhelper/simplereferenceobject.hxx>
|
||||||
|
|
||||||
#include <osl/diagnose.h>
|
|
||||||
#include <osl/thread.hxx>
|
#include <osl/thread.hxx>
|
||||||
#include <osl/conditn.hxx>
|
#include <osl/conditn.hxx>
|
||||||
#include <osl/mutex.hxx>
|
#include <osl/mutex.hxx>
|
||||||
@@ -106,12 +105,8 @@ void Timer::start()
|
|||||||
|
|
||||||
TimerManager *pManager = TimerManager::getTimerManager();
|
TimerManager *pManager = TimerManager::getTimerManager();
|
||||||
|
|
||||||
OSL_ASSERT(pManager);
|
if (pManager)
|
||||||
|
|
||||||
if (pManager != nullptr)
|
|
||||||
{
|
|
||||||
pManager->registerTimer(this);
|
pManager->registerTimer(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,25 +114,18 @@ void Timer::stop()
|
|||||||
{
|
{
|
||||||
TimerManager *pManager = TimerManager::getTimerManager();
|
TimerManager *pManager = TimerManager::getTimerManager();
|
||||||
|
|
||||||
OSL_ASSERT(pManager);
|
if (pManager)
|
||||||
|
|
||||||
if (pManager != nullptr)
|
|
||||||
{
|
|
||||||
pManager->unregisterTimer(this);
|
pManager->unregisterTimer(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sal_Bool Timer::isTicking() const
|
sal_Bool Timer::isTicking() const
|
||||||
{
|
{
|
||||||
TimerManager *pManager = TimerManager::getTimerManager();
|
TimerManager *pManager = TimerManager::getTimerManager();
|
||||||
|
|
||||||
OSL_ASSERT(pManager);
|
|
||||||
|
|
||||||
if (pManager)
|
if (pManager)
|
||||||
return pManager->lookupTimer(this);
|
return pManager->lookupTimer(this);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sal_Bool Timer::isExpired() const
|
sal_Bool Timer::isExpired() const
|
||||||
@@ -151,16 +139,10 @@ sal_Bool Timer::isExpired() const
|
|||||||
|
|
||||||
sal_Bool Timer::expiresBefore(const Timer* pTimer) const
|
sal_Bool Timer::expiresBefore(const Timer* pTimer) const
|
||||||
{
|
{
|
||||||
OSL_ASSERT(pTimer);
|
if (pTimer)
|
||||||
|
|
||||||
if (pTimer != nullptr)
|
|
||||||
{
|
|
||||||
return m_aExpired < pTimer->m_aExpired;
|
return m_aExpired < pTimer->m_aExpired;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer::setAbsoluteTime(const TTimeValue& Time)
|
void Timer::setAbsoluteTime(const TTimeValue& Time)
|
||||||
@@ -242,12 +224,10 @@ TimerManager::TimerManager()
|
|||||||
{
|
{
|
||||||
osl::MutexGuard Guard(theTimerManagerMutex::get());
|
osl::MutexGuard Guard(theTimerManagerMutex::get());
|
||||||
|
|
||||||
OSL_ASSERT(m_pManager == nullptr);
|
assert(m_pManager == nullptr);
|
||||||
|
|
||||||
m_pManager = this;
|
m_pManager = this;
|
||||||
|
|
||||||
m_pHead= nullptr;
|
m_pHead= nullptr;
|
||||||
|
|
||||||
m_notEmpty.reset();
|
m_notEmpty.reset();
|
||||||
|
|
||||||
// start thread
|
// start thread
|
||||||
@@ -258,7 +238,7 @@ TimerManager::~TimerManager()
|
|||||||
{
|
{
|
||||||
osl::MutexGuard Guard(theTimerManagerMutex::get());
|
osl::MutexGuard Guard(theTimerManagerMutex::get());
|
||||||
|
|
||||||
if ( m_pManager == this )
|
if (m_pManager == this)
|
||||||
m_pManager = nullptr;
|
m_pManager = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,12 +259,8 @@ TimerManager* TimerManager::getTimerManager()
|
|||||||
|
|
||||||
void TimerManager::registerTimer(Timer* pTimer)
|
void TimerManager::registerTimer(Timer* pTimer)
|
||||||
{
|
{
|
||||||
OSL_ASSERT(pTimer);
|
if (!pTimer)
|
||||||
|
|
||||||
if ( pTimer == nullptr )
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
osl::MutexGuard Guard(m_Lock);
|
osl::MutexGuard Guard(m_Lock);
|
||||||
|
|
||||||
@@ -318,12 +294,8 @@ void TimerManager::registerTimer(Timer* pTimer)
|
|||||||
|
|
||||||
void TimerManager::unregisterTimer(Timer* pTimer)
|
void TimerManager::unregisterTimer(Timer* pTimer)
|
||||||
{
|
{
|
||||||
OSL_ASSERT(pTimer);
|
if (!pTimer)
|
||||||
|
|
||||||
if ( pTimer == nullptr )
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// lock access
|
// lock access
|
||||||
osl::MutexGuard Guard(m_Lock);
|
osl::MutexGuard Guard(m_Lock);
|
||||||
@@ -344,12 +316,8 @@ void TimerManager::unregisterTimer(Timer* pTimer)
|
|||||||
|
|
||||||
bool TimerManager::lookupTimer(const Timer* pTimer)
|
bool TimerManager::lookupTimer(const Timer* pTimer)
|
||||||
{
|
{
|
||||||
OSL_ASSERT(pTimer);
|
if (!pTimer)
|
||||||
|
|
||||||
if ( pTimer == nullptr )
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
// lock access
|
// lock access
|
||||||
osl::MutexGuard Guard(m_Lock);
|
osl::MutexGuard Guard(m_Lock);
|
||||||
@@ -358,9 +326,7 @@ bool TimerManager::lookupTimer(const Timer* pTimer)
|
|||||||
for (Timer* pIter = m_pHead; pIter != nullptr; pIter= pIter->m_pNext)
|
for (Timer* pIter = m_pHead; pIter != nullptr; pIter= pIter->m_pNext)
|
||||||
{
|
{
|
||||||
if (pIter == pTimer)
|
if (pIter == pTimer)
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -368,10 +334,9 @@ bool TimerManager::lookupTimer(const Timer* pTimer)
|
|||||||
|
|
||||||
void TimerManager::checkForTimeout()
|
void TimerManager::checkForTimeout()
|
||||||
{
|
{
|
||||||
|
|
||||||
m_Lock.acquire();
|
m_Lock.acquire();
|
||||||
|
|
||||||
if ( m_pHead == nullptr )
|
if (!m_pHead)
|
||||||
{
|
{
|
||||||
m_Lock.release();
|
m_Lock.release();
|
||||||
return;
|
return;
|
||||||
@@ -391,7 +356,7 @@ void TimerManager::checkForTimeout()
|
|||||||
pTimer->onShot();
|
pTimer->onShot();
|
||||||
|
|
||||||
// restart timer if specified
|
// restart timer if specified
|
||||||
if ( ! pTimer->m_aRepeatDelta.isEmpty() )
|
if (!pTimer->m_aRepeatDelta.isEmpty())
|
||||||
{
|
{
|
||||||
TTimeValue Now;
|
TTimeValue Now;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user