[{"id":4755,"web_url":"https://patchwork.libcamera.org/comment/4755/","msgid":"<20200506205316.GF15206@pendragon.ideasonboard.com>","date":"2020-05-06T20:53:16","subject":"Re: [libcamera-devel] [PATCH 2/4] libcamera: camera_manager:\n\tIntroduce signals when a camera is added/removed","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nThank you for the patch.\n\nOn Wed, May 06, 2020 at 10:33:53AM +0000, Umang Jain wrote:\n> Emit 'cameraAdded' and 'cameraRemoved' from CameraManager to enable\n> hotplug and hot-unplug support in appplications like QCam.\n> \n> Signed-off-by: Umang Jain <email@uajain.com>\n> ---\n>  include/libcamera/camera_manager.h |  4 ++++\n>  src/libcamera/camera_manager.cpp   | 20 ++++++++++++++++++++\n>  2 files changed, 24 insertions(+)\n> \n> diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h\n> index 079f848..558bb96 100644\n> --- a/include/libcamera/camera_manager.h\n> +++ b/include/libcamera/camera_manager.h\n> @@ -13,6 +13,7 @@\n>  #include <vector>\n>  \n>  #include <libcamera/object.h>\n> +#include <libcamera/signal.h>\n>  \n>  namespace libcamera {\n>  \n> @@ -42,6 +43,9 @@ public:\n>  \tvoid setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher);\n>  \tEventDispatcher *eventDispatcher();\n>  \n> +\tSignal<Camera *> cameraAdded;\n> +\tSignal<Camera *> cameraRemoved;\n> +\n>  private:\n>  \tstatic const std::string version_;\n>  \tstatic CameraManager *self_;\n> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n> index c75979a..6438f87 100644\n> --- a/src/libcamera/camera_manager.cpp\n> +++ b/src/libcamera/camera_manager.cpp\n> @@ -391,6 +391,23 @@ std::shared_ptr<Camera> CameraManager::get(dev_t devnum)\n>  \treturn iter->second.lock();\n>  }\n>  \n> +/**\n> + * \\var CameraManager::cameraAdded\n> + * \\brief Signal emitted when a new camera is added in CameraManager\n> + *\n> + * This signal is emitted when a new camera is added by the CameraManager\n> + * in the list of cameras it manages. A pointer to the newly-added camera\n> + * is passed as a parameter.\n\nI think we should detail here the relationship with\nCameraManager::start() and CameraManager::cameras(), and note that the\nsignal handler should be fast (otherwise it would block operation of\nother cameras). How about the following ?\n\n * \\brief Notify of a new camera added to the system\n *\n * This signal is emitted when a new camera is detected and successfully handled\n * by the camera manager. The notification occurs alike for cameras detected\n * when the manager is started with start() or when new cameras are later\n * connected to the system. When the signal is emitted the new camera is already\n * available from the list of cameras().\n *\n * The signal is emitted from the CameraManager thread. Applications shall\n * minimize the time spent in the signal handler and shall in particular not\n * perform any blocking operation.\n\n> + */\n> +\n> +/**\n> + * \\var CameraManager::cameraRemoved\n> + * \\brief Signal emitted when a camera is removed in CameraManager\n> + *\n> + * This signal is emitted when a camera is removed from the CameraManager.\n> + * A pointer to the removed camera is passed as a parameter.\n\nAnd something similar here ?\n\n * \\brief Notify of a new camera removed from the system\n *\n * This signal is emitted when a camera is removed from the system. When the\n * signal is emitted the camera is not available from the list of cameras()\n * anymore.\n *\n * The signal is emitted from the CameraManager thread. Applications shall\n * minimize the time spent in the signal handler and shall in particular not\n * perform any blocking operation.\n\n> + */\n> +\n>  /**\n>   * \\brief Add a camera to the camera manager\n>   * \\param[in] camera The camera to be added\n> @@ -409,7 +426,9 @@ void CameraManager::addCamera(std::shared_ptr<Camera> camera, dev_t devnum)\n>  {\n>  \tASSERT(Thread::current() == p_.get());\n>  \n> +\tCamera *cam = camera.get();\n>  \tp_->addCamera(camera, devnum);\n> +\tcameraAdded.emit(cam);\n\nYou don't need a local cam variable as camera is a shared pointer, not a\nunique pointer (and if it was a unique pointer and was given to\naddCamera() with std::move, it would be potentially unsafe to use it\nafterwards).\n\n\tcameraAdded.emit(camera.get());\n\nis fine.\n\n>  }\n>  \n>  /**\n> @@ -427,6 +446,7 @@ void CameraManager::removeCamera(Camera *camera)\n>  \tASSERT(Thread::current() == p_.get());\n>  \n>  \tp_->removeCamera(camera);\n> +\tcameraRemoved.emit(camera);\n>  }\n>  \n>  /**","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 32274603F2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 May 2020 22:53:22 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B00BA542;\n\tWed,  6 May 2020 22:53:21 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"LR7O3xYy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1588798401;\n\tbh=2NDdvVVGWc96ByXzIR7aOPAdxf4bLusEuA3MaMaBIsY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=LR7O3xYyWQXoanmAue/3j6kZICFGOie4FE7Tdwt57oQUtfY//bx732vuwHlSvJ8j0\n\t05fFRcSHVcLG3bK30ANM6w3uO7Mwvg0Rh1J14zHkr94AsHI5Dz1OpLiIfvQ+rhub6o\n\tGRC/7sIxWjMEBq/YuvuEQKE49/avoarFFG+5bo7I=","Date":"Wed, 6 May 2020 23:53:16 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <email@uajain.com>","Cc":"libcamera-devel <libcamera-devel@lists.libcamera.org>","Message-ID":"<20200506205316.GF15206@pendragon.ideasonboard.com>","References":"<20200506103346.3433-1-email@uajain.com>\n\t<20200506103346.3433-3-email@uajain.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200506103346.3433-3-email@uajain.com>","Subject":"Re: [libcamera-devel] [PATCH 2/4] libcamera: camera_manager:\n\tIntroduce signals when a camera is added/removed","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Wed, 06 May 2020 20:53:22 -0000"}},{"id":4768,"web_url":"https://patchwork.libcamera.org/comment/4768/","msgid":"<JAM0AQ.0LQYEDAROILH3@uajain.com>","date":"2020-05-08T13:47:15","subject":"Re: [libcamera-devel] [PATCH 2/4] libcamera: camera_manager:\n\tIntroduce signals when a camera is added/removed","submitter":{"id":1,"url":"https://patchwork.libcamera.org/api/people/1/","name":"Umang Jain","email":"email@uajain.com"},"content":"Hi Laurent,\n\nThanks for the feedback.\n\nOn Wed, May 6, 2020 at 23:53, Laurent Pinchart \n<laurent.pinchart@ideasonboard.com> wrote:\n> Hi Umang,\n> \n> Thank you for the patch.\n> \n> On Wed, May 06, 2020 at 10:33:53AM +0000, Umang Jain wrote:\n>>  Emit 'cameraAdded' and 'cameraRemoved' from CameraManager to enable\n>>  hotplug and hot-unplug support in appplications like QCam.\n>> \n>>  Signed-off-by: Umang Jain <email@uajain.com \n>> <mailto:email@uajain.com>>\n>>  ---\n>>   include/libcamera/camera_manager.h |  4 ++++\n>>   src/libcamera/camera_manager.cpp   | 20 ++++++++++++++++++++\n>>   2 files changed, 24 insertions(+)\n>> \n>>  diff --git a/include/libcamera/camera_manager.h \n>> b/include/libcamera/camera_manager.h\n>>  index 079f848..558bb96 100644\n>>  --- a/include/libcamera/camera_manager.h\n>>  +++ b/include/libcamera/camera_manager.h\n>>  @@ -13,6 +13,7 @@\n>>   #include <vector>\n>> \n>>   #include <libcamera/object.h>\n>>  +#include <libcamera/signal.h>\n>> \n>>   namespace libcamera {\n>> \n>>  @@ -42,6 +43,9 @@ public:\n>>   \tvoid setEventDispatcher(std::unique_ptr<EventDispatcher> \n>> dispatcher);\n>>   \tEventDispatcher *eventDispatcher();\n>> \n>>  +\tSignal<Camera *> cameraAdded;\n>>  +\tSignal<Camera *> cameraRemoved;\n>>  +\n>>   private:\n>>   \tstatic const std::string version_;\n>>   \tstatic CameraManager *self_;\n>>  diff --git a/src/libcamera/camera_manager.cpp \n>> b/src/libcamera/camera_manager.cpp\n>>  index c75979a..6438f87 100644\n>>  --- a/src/libcamera/camera_manager.cpp\n>>  +++ b/src/libcamera/camera_manager.cpp\n>>  @@ -391,6 +391,23 @@ std::shared_ptr<Camera> \n>> CameraManager::get(dev_t devnum)\n>>   \treturn iter->second.lock();\n>>   }\n>> \n>>  +/**\n>>  + * \\var CameraManager::cameraAdded\n>>  + * \\brief Signal emitted when a new camera is added in \n>> CameraManager\n>>  + *\n>>  + * This signal is emitted when a new camera is added by the \n>> CameraManager\n>>  + * in the list of cameras it manages. A pointer to the newly-added \n>> camera\n>>  + * is passed as a parameter.\n> \n> I think we should detail here the relationship with\n> CameraManager::start() and CameraManager::cameras(), and note that the\n> signal handler should be fast (otherwise it would block operation of\n> other cameras). How about the following ?\n> \n>  * \\brief Notify of a new camera added to the system\n>  *\n>  * This signal is emitted when a new camera is detected and \n> successfully handled\n>  * by the camera manager. The notification occurs alike for cameras \n> detected\n>  * when the manager is started with start() or when new cameras are \n> later\n>  * connected to the system. When the signal is emitted the new camera \n> is already\n>  * available from the list of cameras().\n>  *\n>  * The signal is emitted from the CameraManager thread. Applications \n> shall\n>  * minimize the time spent in the signal handler and shall in \n> particular not\n>  * perform any blocking operation.\n> \n>>  + */\n>>  +\n>>  +/**\n>>  + * \\var CameraManager::cameraRemoved\n>>  + * \\brief Signal emitted when a camera is removed in CameraManager\n>>  + *\n>>  + * This signal is emitted when a camera is removed from the \n>> CameraManager.\n>>  + * A pointer to the removed camera is passed as a parameter.\n> \n> And something similar here ?\n> \n>  * \\brief Notify of a new camera removed from the system\n>  *\n>  * This signal is emitted when a camera is removed from the system. \n> When the\n>  * signal is emitted the camera is not available from the list of \n> cameras()\n>  * anymore.\n>  *\n>  * The signal is emitted from the CameraManager thread. Applications \n> shall\n>  * minimize the time spent in the signal handler and shall in \n> particular not\n>  * perform any blocking operation.\n> \n>>  + */\n>>  +\n>>   /**\n>>    * \\brief Add a camera to the camera manager\n>>    * \\param[in] camera The camera to be added\n>>  @@ -409,7 +426,9 @@ void \n>> CameraManager::addCamera(std::shared_ptr<Camera> camera, dev_t \n>> devnum)\n>>   {\n>>   \tASSERT(Thread::current() == p_.get());\n>> \n>>  +\tCamera *cam = camera.get();\n>>   \tp_->addCamera(camera, devnum);\n>>  +\tcameraAdded.emit(cam);\n> \n> You don't need a local cam variable as camera is a shared pointer, \n> not a\n> unique pointer (and if it was a unique pointer and was given to\n> addCamera() with std::move, it would be potentially unsafe to use it\n> afterwards).\n> \n> \tcameraAdded.emit(camera.get());\n> \n> is fine.\n\nYes, camera is a shared pointer here and is std::move in \np_->addCamera(camera, devnum);\n But I noticed that camera becomes nullptr after p_->addCamera() call \nand that's\nI would expect. I double-checked with running the codepath with your \nchange,\nand plugging in a camera crashes with a `null` segfault backtrace. Am I \nmissing something?\n\n> \n>>   }\n>> \n>>   /**\n>>  @@ -427,6 +446,7 @@ void CameraManager::removeCamera(Camera *camera)\n>>   \tASSERT(Thread::current() == p_.get());\n>> \n>>   \tp_->removeCamera(camera);\n>>  +\tcameraRemoved.emit(camera);\n>>   }\n>> \n>>   /**\n> \n> --\n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<bounces+15657259-5c31-libcamera-devel=lists.libcamera.org@em7280.uajain.com>","Received":["from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 964D7600EA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 May 2020 15:47:17 +0200 (CEST)","by filter0081p3las1.sendgrid.net with SMTP id\n\tfilter0081p3las1-3357-5EB562E3-33\n\t2020-05-08 13:47:15.402299194 +0000 UTC m=+1957524.696473927","from mail.uajain.com (unknown)\n\tby ismtpd0005p1maa1.sendgrid.net (SG) with ESMTP\n\tid wbiu-h_vTgW3_S8-a6t6Pw Fri, 08 May 2020 13:47:14.995 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=uajain.com\n\theader.i=@uajain.com header.b=\"boQvsDLD\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com;\n\th=from:subject:in-reply-to:references:mime-version:to:cc:content-type;\n\ts=s1; bh=qoRqD+BktDmVRD9ViP/7GBwATbEywm461xpGbifdcdI=;\n\tb=boQvsDLDx33Cy5KGBBC8BzNp0mhJk52U3iXGV7lmNbgjAKpk+b4eLk4bHIJzHYH7j25a\n\tNJqdyNBA2rUWsul44yq2PVXdNT3vmGQNIeoHKnF7nO1F24f9cz3OrYgK0tbf9PlYN9M1t+\n\to+4EGfA6utj8u0vD7qMQ8YQ4oCa7k8IVw=","Date":"Fri, 08 May 2020 13:47:15 +0000 (UTC)","From":"Umang Jain <email@uajain.com>","Message-Id":"<JAM0AQ.0LQYEDAROILH3@uajain.com>","In-Reply-To":"<20200506205316.GF15206@pendragon.ideasonboard.com>","References":"<20200506103346.3433-1-email@uajain.com>\n\t<20200506103346.3433-3-email@uajain.com>\n\t<20200506205316.GF15206@pendragon.ideasonboard.com>","Mime-Version":"1.0","X-SG-EID":"1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcjYEmjroJWz9HTg4fTt6n9aOWiwvQ4oJ9yO79LATinULhY0OvMH7e9IysOhyP0YJ8NCFVPDrEkBGxr4eKTVHzhSfiG1l/ttRnxjzcoLgOd6+hdxNtWeIR+R4RF3HWBUbvzA6sdajGLGfdoTPAAHUU3vL1w9wYbELTi1YaOhHbOvausVok2CMbuKWlpO7eULmQ","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel <libcamera-devel@lists.libcamera.org>","Content-Type":"multipart/alternative; boundary=\"=-crVuCqxk/3xxbjAXt1YQ\"","Subject":"Re: [libcamera-devel] [PATCH 2/4] libcamera: camera_manager:\n\tIntroduce signals when a camera is added/removed","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 08 May 2020 13:47:18 -0000"}},{"id":5107,"web_url":"https://patchwork.libcamera.org/comment/5107/","msgid":"<20200607163905.GA19672@pendragon.ideasonboard.com>","date":"2020-06-07T16:39:05","subject":"Re: [libcamera-devel] [PATCH 2/4] libcamera: camera_manager:\n\tIntroduce signals when a camera is added/removed","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nOn Fri, May 08, 2020 at 01:47:15PM +0000, Umang Jain wrote:\n> On Wed, May 6, 2020 at 23:53, Laurent Pinchart wrote:\n> > On Wed, May 06, 2020 at 10:33:53AM +0000, Umang Jain wrote:\n> >>  Emit 'cameraAdded' and 'cameraRemoved' from CameraManager to enable\n> >>  hotplug and hot-unplug support in appplications like QCam.\n> >> \n> >>  Signed-off-by: Umang Jain <email@uajain.com>\n> >>  ---\n> >>   include/libcamera/camera_manager.h |  4 ++++\n> >>   src/libcamera/camera_manager.cpp   | 20 ++++++++++++++++++++\n> >>   2 files changed, 24 insertions(+)\n> >> \n> >>  diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h\n> >>  index 079f848..558bb96 100644\n> >>  --- a/include/libcamera/camera_manager.h\n> >>  +++ b/include/libcamera/camera_manager.h\n> >>  @@ -13,6 +13,7 @@\n> >>   #include <vector>\n> >> \n> >>   #include <libcamera/object.h>\n> >>  +#include <libcamera/signal.h>\n> >> \n> >>   namespace libcamera {\n> >> \n> >>  @@ -42,6 +43,9 @@ public:\n> >>   \tvoid setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher);\n> >>   \tEventDispatcher *eventDispatcher();\n> >> \n> >>  +\tSignal<Camera *> cameraAdded;\n> >>  +\tSignal<Camera *> cameraRemoved;\n> >>  +\n> >>   private:\n> >>   \tstatic const std::string version_;\n> >>   \tstatic CameraManager *self_;\n> >>  diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n> >>  index c75979a..6438f87 100644\n> >>  --- a/src/libcamera/camera_manager.cpp\n> >>  +++ b/src/libcamera/camera_manager.cpp\n> >>  @@ -391,6 +391,23 @@ std::shared_ptr<Camera> CameraManager::get(dev_t devnum)\n> >>   \treturn iter->second.lock();\n> >>   }\n> >> \n> >>  +/**\n> >>  + * \\var CameraManager::cameraAdded\n> >>  + * \\brief Signal emitted when a new camera is added in CameraManager\n> >>  + *\n> >>  + * This signal is emitted when a new camera is added by the CameraManager\n> >>  + * in the list of cameras it manages. A pointer to the newly-added camera\n> >>  + * is passed as a parameter.\n> > \n> > I think we should detail here the relationship with\n> > CameraManager::start() and CameraManager::cameras(), and note that the\n> > signal handler should be fast (otherwise it would block operation of\n> > other cameras). How about the following ?\n> > \n> >  * \\brief Notify of a new camera added to the system\n> >  *\n> >  * This signal is emitted when a new camera is detected and successfully handled\n> >  * by the camera manager. The notification occurs alike for cameras detected\n> >  * when the manager is started with start() or when new cameras are later\n> >  * connected to the system. When the signal is emitted the new camera is already\n> >  * available from the list of cameras().\n> >  *\n> >  * The signal is emitted from the CameraManager thread. Applications shall\n> >  * minimize the time spent in the signal handler and shall in particular not\n> >  * perform any blocking operation.\n> > \n> >>  + */\n> >>  +\n> >>  +/**\n> >>  + * \\var CameraManager::cameraRemoved\n> >>  + * \\brief Signal emitted when a camera is removed in CameraManager\n> >>  + *\n> >>  + * This signal is emitted when a camera is removed from the CameraManager.\n> >>  + * A pointer to the removed camera is passed as a parameter.\n> > \n> > And something similar here ?\n> > \n> >  * \\brief Notify of a new camera removed from the system\n> >  *\n> >  * This signal is emitted when a camera is removed from the system. When the\n> >  * signal is emitted the camera is not available from the list of cameras()\n> >  * anymore.\n> >  *\n> >  * The signal is emitted from the CameraManager thread. Applications shall\n> >  * minimize the time spent in the signal handler and shall in particular not\n> >  * perform any blocking operation.\n> > \n> >>  + */\n> >>  +\n> >>   /**\n> >>    * \\brief Add a camera to the camera manager\n> >>    * \\param[in] camera The camera to be added\n> >>  @@ -409,7 +426,9 @@ void \n> >> CameraManager::addCamera(std::shared_ptr<Camera> camera, dev_t \n> >> devnum)\n> >>   {\n> >>   \tASSERT(Thread::current() == p_.get());\n> >> \n> >>  +\tCamera *cam = camera.get();\n> >>   \tp_->addCamera(camera, devnum);\n> >>  +\tcameraAdded.emit(cam);\n> > \n> > You don't need a local cam variable as camera is a shared pointer, not a\n> > unique pointer (and if it was a unique pointer and was given to\n> > addCamera() with std::move, it would be potentially unsafe to use it\n> > afterwards).\n> > \n> > \tcameraAdded.emit(camera.get());\n> > \n> > is fine.\n> \n> Yes, camera is a shared pointer here and is std::move in p_->addCamera(camera, devnum);\n> But I noticed that camera becomes nullptr after p_->addCamera() call and that's\n> I would expect. I double-checked with running the codepath with your change,\n> and plugging in a camera crashes with a `null` segfault backtrace. Am I missing something?\n\nYou were absolutely right, I had missed the fact that p_->addCamera()\ntakes a non-const reference and uses std::move internally.\n\n> >>   }\n> >> \n> >>   /**\n> >>  @@ -427,6 +446,7 @@ void CameraManager::removeCamera(Camera *camera)\n> >>   \tASSERT(Thread::current() == p_.get());\n> >> \n> >>   \tp_->removeCamera(camera);\n> >>  +\tcameraRemoved.emit(camera);\n> >>   }\n> >> \n> >>   /**","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E792F600F7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  7 Jun 2020 18:39:24 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 61B1C2C9;\n\tSun,  7 Jun 2020 18:39:24 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Sr997PBA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1591547964;\n\tbh=IeRgBWwSrY4fKGqiXp4kqsgcP0fGeQ6vE2PLnZErHus=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Sr997PBAKQbRr/3CfohV1aPi+tkPfFwYAgDxnOXB/feSUjQMk2jyNaf403DXLR/Kh\n\tdU5qKPlPg6gFC/eOfAidh82l6Ks4NXNRIbLoV12SnN8ixjG1kGhBwSAgH/OIaNZ+z4\n\tJqsbcAmDku3x55rTHHPqpNMqq8By75lsZnc2FtJU=","Date":"Sun, 7 Jun 2020 19:39:05 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <email@uajain.com>","Cc":"libcamera-devel <libcamera-devel@lists.libcamera.org>","Message-ID":"<20200607163905.GA19672@pendragon.ideasonboard.com>","References":"<20200506103346.3433-1-email@uajain.com>\n\t<20200506103346.3433-3-email@uajain.com>\n\t<20200506205316.GF15206@pendragon.ideasonboard.com>\n\t<JAM0AQ.0LQYEDAROILH3@uajain.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<JAM0AQ.0LQYEDAROILH3@uajain.com>","Subject":"Re: [libcamera-devel] [PATCH 2/4] libcamera: camera_manager:\n\tIntroduce signals when a camera is added/removed","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sun, 07 Jun 2020 16:39:25 -0000"}}]