summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-06-30 17:20:01 +0200
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-07-01 23:48:03 +0200
commit08b2e03a8ac4758e4973d7fd549026ebeb28ff29 (patch)
tree12a5a92cfe59d316eeaee1c40e826f52d0e558f5
parentdba2de3a0feddddf2774b75c1bcc8ed0c6bd54c5 (diff)
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>
-rw-r--r--include/libcamera/timer.h1
-rw-r--r--src/libcamera/timer.cpp5
2 files changed, 6 insertions, 0 deletions
diff --git a/include/libcamera/timer.h b/include/libcamera/timer.h
index 97dcc01f..f082339b 100644
--- a/include/libcamera/timer.h
+++ b/include/libcamera/timer.h
@@ -17,6 +17,7 @@ class Timer
{
public:
Timer();
+ ~Timer();
void start(unsigned int msec);
void stop();
diff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp
index 1cce4508..0dcb4e76 100644
--- a/src/libcamera/timer.cpp
+++ b/src/libcamera/timer.cpp
@@ -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