From 4d85f6d4fab454963a1f09504b4b88ee090deb9b Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Tue, 21 Aug 2018 17:53:59 +0200 Subject: [PATCH] camera: try to fix double free on descruction Sometimes after the integration tests ran on destruction I would get double free of the callbacks. Presumably this was because a callback is being deleted while being executed. --- plugins/camera/camera_impl.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugins/camera/camera_impl.cpp b/plugins/camera/camera_impl.cpp index 6ba6ffcbc0..23e0e71b82 100644 --- a/plugins/camera/camera_impl.cpp +++ b/plugins/camera/camera_impl.cpp @@ -22,6 +22,26 @@ CameraImpl::CameraImpl(System &system) : PluginImplBase(system) CameraImpl::~CameraImpl() { _parent->unregister_plugin(this); + + { + std::lock_guard lock(_status.mutex); + _status.callback = nullptr; + } + + { + std::lock_guard lock(_get_mode.mutex); + _get_mode.callback = nullptr; + } + + { + std::lock_guard lock(_capture_info.mutex); + _capture_info.callback = nullptr; + } + + { + std::lock_guard lock(_video_stream_info.mutex); + _video_stream_info.callback = nullptr; + } } void CameraImpl::init()