[PATCH] libcamera: Add static Object::Deleter function
Harvey Yang
chenghaoyang at chromium.org
Wed Oct 23 18:58:04 CEST 2024
This patch allows a smart pointer of Object to be destructed in other
threads.
There will be multiple usages of smart pointers of Object. This patch
adds the deleter function to avoid duplicated code.
Signed-off-by: Harvey Yang <chenghaoyang at chromium.org>
---
include/libcamera/base/object.h | 2 ++
src/libcamera/base/object.cpp | 11 +++++++++++
2 files changed, 13 insertions(+)
diff --git a/include/libcamera/base/object.h b/include/libcamera/base/object.h
index 508773cd0..c4522d480 100644
--- a/include/libcamera/base/object.h
+++ b/include/libcamera/base/object.h
@@ -24,6 +24,8 @@ class Thread;
class Object
{
public:
+ static void Deleter(Object *obj);
+
Object(Object *parent = nullptr);
virtual ~Object();
diff --git a/src/libcamera/base/object.cpp b/src/libcamera/base/object.cpp
index 745d2565a..2c04b99a5 100644
--- a/src/libcamera/base/object.cpp
+++ b/src/libcamera/base/object.cpp
@@ -59,6 +59,17 @@ LOG_DEFINE_CATEGORY(Object)
* \sa Message, Signal, Thread
*/
+/**
+ * \brief A deleter function that calls Object::deleteLater
+ * \param[in] obj The object itself
+ *
+ * The static deleter function that's used in smart pointers.
+ */
+void Object::Deleter(Object *obj)
+{
+ obj->deleteLater();
+}
+
/**
* \brief Construct an Object instance
* \param[in] parent The object parent
--
2.47.0.105.g07ac214952-goog
More information about the libcamera-devel
mailing list