[libcamera-devel] [PATCH 08/19] test: signal: Add additional disconnection tests for Object

Niklas Söderlund niklas.soderlund at ragnatech.se
Wed Jan 22 16:20:19 CET 2020


Hi Laurent,

Thanks for your test.

On 2020-01-20 02:24:26 +0200, Laurent Pinchart wrote:
> Add two tests that exercise the Signal::disconnect(Object *) and
> Signal::disconnect() methods, to verify that they correctly remove the
> signal from the connected object's list of signals. This triggers an
> issue that was detected through manual code inspection, and is expected
> to crash or at least generate valgrind warnings.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>

> ---
>  test/signal.cpp | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/test/signal.cpp b/test/signal.cpp
> index 0054ed5a380d..f83ceb05f091 100644
> --- a/test/signal.cpp
> +++ b/test/signal.cpp
> @@ -220,6 +220,30 @@ protected:
>  		delete dynamicSignal;
>  		delete slotObject;
>  
> +		/*
> +		 * Test that signal manual disconnection from Object removes
> +		 * the signal for the object. This shall not generate any
> +		 * valgrind warning.
> +		 */
> +		dynamicSignal = new Signal<>();
> +		slotObject = new SlotObject();
> +		dynamicSignal->connect(slotObject, &SlotObject::slot);
> +		dynamicSignal->disconnect(slotObject);
> +		delete dynamicSignal;
> +		delete slotObject;
> +
> +		/*
> +		 * Test that signal manual disconnection from all slots removes
> +		 * the signal for the object. This shall not generate any
> +		 * valgrind warning.
> +		 */
> +		dynamicSignal = new Signal<>();
> +		slotObject = new SlotObject();
> +		dynamicSignal->connect(slotObject, &SlotObject::slot);
> +		dynamicSignal->disconnect();
> +		delete dynamicSignal;
> +		delete slotObject;
> +
>  		/* Exercise the Object slot code paths. */
>  		slotObject = new SlotObject();
>  		signalVoid_.connect(slotObject, &SlotObject::slot);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

-- 
Regards,
Niklas Söderlund


More information about the libcamera-devel mailing list