Message ID | 20190812124642.24287-11-laurent.pinchart@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thanks for your work. On 2019-08-12 15:46:34 +0300, Laurent Pinchart wrote: > The CameraManager class uses the event dispatcher of the current thread. > This makes the CameraManager::eventDispatcher() and > CameraManager::setEventDispatcher() methods inconsistent, as they access > different event dispatcher instances depending on the calling thread. > > Fix this by inheriting from the Object class, which binds the > CameraManager to a thread, and use the event dispatcher of the bound > thread. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > include/libcamera/camera_manager.h | 4 +++- > src/libcamera/camera_manager.cpp | 4 ++-- > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h > index 0e8881baba40..ff7d4c7c6745 100644 > --- a/include/libcamera/camera_manager.h > +++ b/include/libcamera/camera_manager.h > @@ -11,6 +11,8 @@ > #include <string> > #include <vector> > > +#include <libcamera/object.h> > + > namespace libcamera { > > class Camera; > @@ -18,7 +20,7 @@ class DeviceEnumerator; > class EventDispatcher; > class PipelineHandler; > > -class CameraManager > +class CameraManager : public Object > { > public: > int start(); > diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp > index 2cf014233b05..4a880684c5cb 100644 > --- a/src/libcamera/camera_manager.cpp > +++ b/src/libcamera/camera_manager.cpp > @@ -248,7 +248,7 @@ CameraManager *CameraManager::instance() > */ > void CameraManager::setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher) > { > - Thread::current()->setEventDispatcher(std::move(dispatcher)); > + thread()->setEventDispatcher(std::move(dispatcher)); > } > > /** > @@ -264,7 +264,7 @@ void CameraManager::setEventDispatcher(std::unique_ptr<EventDispatcher> dispatch > */ > EventDispatcher *CameraManager::eventDispatcher() > { > - return Thread::current()->eventDispatcher(); > + return thread()->eventDispatcher(); > } > > } /* namespace libcamera */ > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index 0e8881baba40..ff7d4c7c6745 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -11,6 +11,8 @@ #include <string> #include <vector> +#include <libcamera/object.h> + namespace libcamera { class Camera; @@ -18,7 +20,7 @@ class DeviceEnumerator; class EventDispatcher; class PipelineHandler; -class CameraManager +class CameraManager : public Object { public: int start(); diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index 2cf014233b05..4a880684c5cb 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -248,7 +248,7 @@ CameraManager *CameraManager::instance() */ void CameraManager::setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher) { - Thread::current()->setEventDispatcher(std::move(dispatcher)); + thread()->setEventDispatcher(std::move(dispatcher)); } /** @@ -264,7 +264,7 @@ void CameraManager::setEventDispatcher(std::unique_ptr<EventDispatcher> dispatch */ EventDispatcher *CameraManager::eventDispatcher() { - return Thread::current()->eventDispatcher(); + return thread()->eventDispatcher(); } } /* namespace libcamera */
The CameraManager class uses the event dispatcher of the current thread. This makes the CameraManager::eventDispatcher() and CameraManager::setEventDispatcher() methods inconsistent, as they access different event dispatcher instances depending on the calling thread. Fix this by inheriting from the Object class, which binds the CameraManager to a thread, and use the event dispatcher of the bound thread. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- include/libcamera/camera_manager.h | 4 +++- src/libcamera/camera_manager.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-)