[RFC PATCH v1] libcamera: base: object,thread: Disable copy/move

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Feb 3 17:21:48 CET 2025


Hi Barnabás,

Thank you for the patch.

On Thu, Jan 30, 2025 at 07:54:33PM +0000, Barnabás Pőcze wrote:
> Objects of type `Object` and `Thread` have address identities, so they
> should not be just moved/copied. And the special member functions
> generated by the compiler do not do the right thing. So delete them.
> 
> Signed-off-by: Barnabás Pőcze <pobrn at protonmail.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> ---
>  include/libcamera/base/object.h | 3 +++
>  include/libcamera/base/thread.h | 3 +++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/include/libcamera/base/object.h b/include/libcamera/base/object.h
> index 508773cd0..6cb935a04 100644
> --- a/include/libcamera/base/object.h
> +++ b/include/libcamera/base/object.h
> @@ -12,6 +12,7 @@
>  #include <vector>
>  
>  #include <libcamera/base/bound_method.h>
> +#include <libcamera/base/class.h>
>  
>  namespace libcamera {
>  
> @@ -52,6 +53,8 @@ protected:
>  	bool assertThreadBound(const char *message);
>  
>  private:
> +	LIBCAMERA_DISABLE_COPY_AND_MOVE(Object)
> +
>  	friend class SignalBase;
>  	friend class Thread;
>  
> diff --git a/include/libcamera/base/thread.h b/include/libcamera/base/thread.h
> index 3209d4f7c..3cbf6398e 100644
> --- a/include/libcamera/base/thread.h
> +++ b/include/libcamera/base/thread.h
> @@ -13,6 +13,7 @@
>  
>  #include <libcamera/base/private.h>
>  
> +#include <libcamera/base/class.h>
>  #include <libcamera/base/message.h>
>  #include <libcamera/base/signal.h>
>  #include <libcamera/base/span.h>
> @@ -54,6 +55,8 @@ protected:
>  	virtual void run();
>  
>  private:
> +	LIBCAMERA_DISABLE_COPY_AND_MOVE(Thread)
> +
>  	void startThread();
>  	void finishThread();
>  

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list