[libcamera-devel,0/2] Add Object::deleteLater() support
mbox series

Message ID 20200728105541.13326-1-email@uajain.com
Headers show
Series
  • Add Object::deleteLater() support
Related show

Message

Umang Jain July 28, 2020, 10:57 a.m. UTC
Implementation of Object::deleteLater() which ensures shared objects
are deleted in the thread to which they belong. This fixes the issue
where on hot-unplug, the Camera object is deleted in QCam's application
thread instead of CameraManager's thread and triggering the ASSERT()
in processNotifier (since the event notifier got deleted out of 
context in a different thread). See [1] for discussion.

[1] https://lists.libcamera.org/pipermail/libcamera-devel/2020-July/010951.html

Umang Jain (2):
  libcamera: object: Add deleteLater() support
  libcamera: camera: Ensure deletion via deleteLater()

 include/libcamera/camera.h           |  2 +-
 include/libcamera/internal/message.h |  1 +
 include/libcamera/object.h           |  2 ++
 src/libcamera/camera.cpp             |  2 +-
 src/libcamera/object.cpp             | 20 ++++++++++++++++++++
 5 files changed, 25 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart July 28, 2020, 3:27 p.m. UTC | #1
Hi Umang,

On Tue, Jul 28, 2020 at 10:57:21AM +0000, Umang Jain wrote:
> Implementation of Object::deleteLater() which ensures shared objects
> are deleted in the thread to which they belong. This fixes the issue
> where on hot-unplug, the Camera object is deleted in QCam's application
> thread instead of CameraManager's thread and triggering the ASSERT()
> in processNotifier (since the event notifier got deleted out of 
> context in a different thread). See [1] for discussion.
> 
> [1] https://lists.libcamera.org/pipermail/libcamera-devel/2020-July/010951.html
> 
> Umang Jain (2):
>   libcamera: object: Add deleteLater() support
>   libcamera: camera: Ensure deletion via deleteLater()
> 
>  include/libcamera/camera.h           |  2 +-
>  include/libcamera/internal/message.h |  1 +
>  include/libcamera/object.h           |  2 ++
>  src/libcamera/camera.cpp             |  2 +-
>  src/libcamera/object.cpp             | 20 ++++++++++++++++++++
>  5 files changed, 25 insertions(+), 2 deletions(-)

It's a nice and simple fix :-)

Could you add a test case for Object::deleteLater() ? It should test the
function both when calling from the Object's thread and from a different
thread. In the first case, it would also be nice to call deleteLater()
twice in a row to ensure deletion only occurs once.