Skip to content

Commit

Permalink
camera: try to fix double free on descruction
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
julianoes committed Aug 21, 2018
1 parent aac5d45 commit 4d85f6d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions plugins/camera/camera_impl.cpp
Expand Up @@ -22,6 +22,26 @@ CameraImpl::CameraImpl(System &system) : PluginImplBase(system)
CameraImpl::~CameraImpl()
{
_parent->unregister_plugin(this);

{
std::lock_guard<std::mutex> lock(_status.mutex);
_status.callback = nullptr;
}

{
std::lock_guard<std::mutex> lock(_get_mode.mutex);
_get_mode.callback = nullptr;
}

{
std::lock_guard<std::mutex> lock(_capture_info.mutex);
_capture_info.callback = nullptr;
}

{
std::lock_guard<std::mutex> lock(_video_stream_info.mutex);
_video_stream_info.callback = nullptr;
}
}

void CameraImpl::init()
Expand Down

0 comments on commit 4d85f6d

Please sign in to comment.