libcamera: timer: Stop timer when it is deleted

If a timer is running while it's deleted it is still register with the
event dispatcher. This causes a segmentation fault when the timer
time-out and its signal is emitted. Fix this my stopping the timer when
it's deleted.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Niklas Söderlund
2019-06-30 17:20:01 +02:00
parent dba2de3a0f
commit 08b2e03a8a
2 changed files with 6 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ class Timer
{
public:
Timer();
~Timer();
void start(unsigned int msec);
void stop();

View File

@@ -43,6 +43,11 @@ Timer::Timer()
{
}
Timer::~Timer()
{
stop();
}
/**
* \brief Start or restart the timer with a timeout of \a msec
* \param[in] msec The timer duration in milliseconds