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

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

Message

Umang Jain July 31, 2020, 1:39 p.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

Changes in v3:
  - Address review for 1/3. dispatchMessages() message loop changed to support
    handling dispatching of all or per type messages.

Changes in v2:
  - Extend Thread::setEventDispatcher to selectively deliver messages
    - This will help if we want to explicitly deliver some messages if
      event loop is not running.
  - Include Object::deleteLater() unit test
    - One \todo here as one case pending to cover; multiple
      deleteLater() should only delete the object once.
  - Review comments (mostly documentation fixes).

Umang Jain (3):
  libcamera: thread: Support selective message dispatch to thread
  libcamera: object: Add deleteLater() support
  libcamera: camera: Ensure deletion via deleteLater()

 include/libcamera/camera.h           |   3 +-
 include/libcamera/internal/message.h |   1 +
 include/libcamera/internal/thread.h  |   3 +-
 include/libcamera/object.h           |   2 +
 src/libcamera/camera.cpp             |   2 +-
 src/libcamera/camera_manager.cpp     |   6 +-
 src/libcamera/message.cpp            |   2 +
 src/libcamera/object.cpp             |  48 ++++++++++
 src/libcamera/thread.cpp             |  30 +++++--
 test/meson.build                     |   1 +
 test/object-delete.cpp               | 125 +++++++++++++++++++++++++++
 11 files changed, 210 insertions(+), 13 deletions(-)
 create mode 100644 test/object-delete.cpp