[libcamera-devel,18/18] test: Simplify tests with parent-child relationships

Message ID 20190812124642.24287-19-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series
  • Object & Thread enhancements
Related show

Commit Message

Laurent Pinchart Aug. 12, 2019, 12:46 p.m. UTC
Create object instances with a parent to avoid the need for reparenting
objects manually.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 test/event-thread.cpp | 8 +-------
 test/timer-thread.cpp | 8 +-------
 2 files changed, 2 insertions(+), 14 deletions(-)

Comments

Niklas Söderlund Aug. 17, 2019, 3:15 p.m. UTC | #1
Hi Laurent,

Thanks for your work.

On 2019-08-12 15:46:42 +0300, Laurent Pinchart wrote:
> Create object instances with a parent to avoid the need for reparenting
> objects manually.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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

> ---
>  test/event-thread.cpp | 8 +-------
>  test/timer-thread.cpp | 8 +-------
>  2 files changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/test/event-thread.cpp b/test/event-thread.cpp
> index 4a82d49b94f1..58f452339f87 100644
> --- a/test/event-thread.cpp
> +++ b/test/event-thread.cpp
> @@ -26,7 +26,7 @@ public:
>  	{
>  		pipe(pipefd_);
>  
> -		notifier_ = new EventNotifier(pipefd_[0], EventNotifier::Read);
> +		notifier_ = new EventNotifier(pipefd_[0], EventNotifier::Read, this);
>  		notifier_->activated.connect(this, &EventHandler::readReady);
>  	}
>  
> @@ -60,12 +60,6 @@ public:
>  		return notified_;
>  	}
>  
> -	void moveToThread(Thread *thread)
> -	{
> -		Object::moveToThread(thread);
> -		notifier_->moveToThread(thread);
> -	}
> -
>  private:
>  	void readReady(EventNotifier *notifier)
>  	{
> diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp
> index b9373050068c..5c1b4ac4a401 100644
> --- a/test/timer-thread.cpp
> +++ b/test/timer-thread.cpp
> @@ -20,7 +20,7 @@ class TimeoutHandler : public Object
>  {
>  public:
>  	TimeoutHandler()
> -		: timeout_(false)
> +		: timer_(this), timeout_(false)
>  	{
>  		timer_.timeout.connect(this, &TimeoutHandler::timeoutHandler);
>  		timer_.start(100);
> @@ -31,12 +31,6 @@ public:
>  		return timeout_;
>  	}
>  
> -	void moveToThread(Thread *thread)
> -	{
> -		Object::moveToThread(thread);
> -		timer_.moveToThread(thread);
> -	}
> -
>  private:
>  	void timeoutHandler(Timer *timer)
>  	{
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/test/event-thread.cpp b/test/event-thread.cpp
index 4a82d49b94f1..58f452339f87 100644
--- a/test/event-thread.cpp
+++ b/test/event-thread.cpp
@@ -26,7 +26,7 @@  public:
 	{
 		pipe(pipefd_);
 
-		notifier_ = new EventNotifier(pipefd_[0], EventNotifier::Read);
+		notifier_ = new EventNotifier(pipefd_[0], EventNotifier::Read, this);
 		notifier_->activated.connect(this, &EventHandler::readReady);
 	}
 
@@ -60,12 +60,6 @@  public:
 		return notified_;
 	}
 
-	void moveToThread(Thread *thread)
-	{
-		Object::moveToThread(thread);
-		notifier_->moveToThread(thread);
-	}
-
 private:
 	void readReady(EventNotifier *notifier)
 	{
diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp
index b9373050068c..5c1b4ac4a401 100644
--- a/test/timer-thread.cpp
+++ b/test/timer-thread.cpp
@@ -20,7 +20,7 @@  class TimeoutHandler : public Object
 {
 public:
 	TimeoutHandler()
-		: timeout_(false)
+		: timer_(this), timeout_(false)
 	{
 		timer_.timeout.connect(this, &TimeoutHandler::timeoutHandler);
 		timer_.start(100);
@@ -31,12 +31,6 @@  public:
 		return timeout_;
 	}
 
-	void moveToThread(Thread *thread)
-	{
-		Object::moveToThread(thread);
-		timer_.moveToThread(thread);
-	}
-
 private:
 	void timeoutHandler(Timer *timer)
 	{