[libcamera-devel] libcamera: object: Fix deleteLater() sample code

Message ID 20200821064023.12722-1-email@uajain.com
State Accepted
Commit cfb5eb31f6a5194bcab4d0c3f636ebf69431b18e
Headers show
Series
  • [libcamera-devel] libcamera: object: Fix deleteLater() sample code
Related show

Commit Message

Umang Jain Aug. 21, 2020, 6:40 a.m. UTC
Instead of using "delete obj" in the custom deleter of the shared
object, we should have been using the "obj->deleteLater()" to explain
how the deleteLater() API should be used in practice.

Fixes: 9558886f7a85 ("libcamera: object: Add deleteLater() support)
Signed-off-by: Umang Jain <email@uajain.com>
---
 src/libcamera/object.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart Aug. 23, 2020, 10:46 p.m. UTC | #1
Hi Umang,

Thank you for the patch.

On Fri, Aug 21, 2020 at 06:40:28AM +0000, Umang Jain wrote:
> Instead of using "delete obj" in the custom deleter of the shared
> object, we should have been using the "obj->deleteLater()" to explain
> how the deleteLater() API should be used in practice.
> 
> Fixes: 9558886f7a85 ("libcamera: object: Add deleteLater() support)
> Signed-off-by: Umang Jain <email@uajain.com>

Oops, indeed.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Will push shortly.

> ---
>  src/libcamera/object.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp
> index 647ccda..cd83c68 100644
> --- a/src/libcamera/object.cpp
> +++ b/src/libcamera/object.cpp
> @@ -125,7 +125,7 @@ Object::~Object()
>   *     struct Deleter : std::default_delete<MyObject> {
>   *             void operator()(MyObject *obj)
>   *             {
> - *                     delete obj;
> + *                     obj->deleteLater();
>   *             }
>   *     };
>   *

Patch

diff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp
index 647ccda..cd83c68 100644
--- a/src/libcamera/object.cpp
+++ b/src/libcamera/object.cpp
@@ -125,7 +125,7 @@  Object::~Object()
  *     struct Deleter : std::default_delete<MyObject> {
  *             void operator()(MyObject *obj)
  *             {
- *                     delete obj;
+ *                     obj->deleteLater();
  *             }
  *     };
  *