Show a patch.

GET /api/patches/13309/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 13309,
    "url": "https://patchwork.libcamera.org/api/patches/13309/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13309/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20210811232625.17280-2-laurent.pinchart@ideasonboard.com>",
    "date": "2021-08-11T23:26:12",
    "name": "[libcamera-devel,v3,01/14] libcamera: base: extensible: Pass private pointer as unique_ptr<>",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "2849f9787e63617966f73de0f09c9479e6eca2ee",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13309/mbox/",
    "series": [
        {
            "id": 2341,
            "url": "https://patchwork.libcamera.org/api/series/2341/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2341",
            "date": "2021-08-11T23:26:11",
            "name": "libcamera: Replace CameraData with Camera::Private",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/2341/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13309/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13309/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id F0259BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 11 Aug 2021 23:26:37 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BCFBE68864;\n\tThu, 12 Aug 2021 01:26:35 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 31BCF687F0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Aug 2021 01:26:33 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C76A4268\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Aug 2021 01:26:32 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"N4wFZPAW\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628724393;\n\tbh=H2u5dhstkCecZM9hLjgVY+1bubA1b/nvotS1plmbePs=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=N4wFZPAWivV3CGVhGcE2oVgODg7pFmqMcHtyqcB47tY4vHf2+A45Iz/ufiHrw22ec\n\tsH5Erv8gz8MZFZ7dKY4Tw7SVmXraWiX5yGCj69uBe3tOr/HYPiOHZNSk5+R68Q62vS\n\t3HjyaIWRradmzFDvYluVNe9CqfM68EzS3lsLIYA4=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 12 Aug 2021 02:26:12 +0300",
        "Message-Id": "<20210811232625.17280-2-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20210811232625.17280-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20210811232625.17280-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 01/14] libcamera: base: extensible:\n\tPass private pointer as unique_ptr<>",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The Extensible constructor takes a pointer to a Private instance, whose\nlifetime it then manages. Make this explicit in the API by passing the\npointer as a std::unique_ptr<Private>.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/base/class.h    |  2 +-\n src/android/camera_buffer.h       |  2 +-\n src/android/camera_hal_config.cpp |  2 +-\n src/libcamera/base/class.cpp      | 11 +++++++++--\n src/libcamera/camera.cpp          |  2 +-\n src/libcamera/camera_manager.cpp  |  2 +-\n src/libcamera/framebuffer.cpp     |  3 ++-\n 7 files changed, 16 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/include/libcamera/base/class.h b/include/libcamera/base/class.h\nindex a5946836d2b9..9a82d61472c1 100644\n--- a/include/libcamera/base/class.h\n+++ b/include/libcamera/base/class.h\n@@ -87,7 +87,7 @@ public:\n \t\tExtensible *const o_;\n \t};\n \n-\tExtensible(Private *d);\n+\tExtensible(std::unique_ptr<Private> d);\n \n protected:\n \ttemplate<typename T>\ndiff --git a/src/android/camera_buffer.h b/src/android/camera_buffer.h\nindex 21373fa25bf8..c4e3a9e7b912 100644\n--- a/src/android/camera_buffer.h\n+++ b/src/android/camera_buffer.h\n@@ -32,7 +32,7 @@ public:\n \n #define PUBLIC_CAMERA_BUFFER_IMPLEMENTATION\t\t\t\t\\\n CameraBuffer::CameraBuffer(buffer_handle_t camera3Buffer, int flags)\t\\\n-\t: Extensible(new Private(this, camera3Buffer, flags))\t\t\\\n+\t: Extensible(std::make_unique<Private>(this, camera3Buffer, flags)) \\\n {\t\t\t\t\t\t\t\t\t\\\n }\t\t\t\t\t\t\t\t\t\\\n CameraBuffer::~CameraBuffer()\t\t\t\t\t\t\\\ndiff --git a/src/android/camera_hal_config.cpp b/src/android/camera_hal_config.cpp\nindex 14549083a97a..aa90dac78075 100644\n--- a/src/android/camera_hal_config.cpp\n+++ b/src/android/camera_hal_config.cpp\n@@ -341,7 +341,7 @@ int CameraHalConfig::Private::parseConfigFile(FILE *fh,\n }\n \n CameraHalConfig::CameraHalConfig()\n-\t: Extensible(new Private()), exists_(false), valid_(false)\n+\t: Extensible(std::make_unique<Private>()), exists_(false), valid_(false)\n {\n \tparseConfigurationFile();\n }\ndiff --git a/src/libcamera/base/class.cpp b/src/libcamera/base/class.cpp\nindex d24043c20e55..9c2d9f218bd4 100644\n--- a/src/libcamera/base/class.cpp\n+++ b/src/libcamera/base/class.cpp\n@@ -147,9 +147,12 @@ namespace libcamera {\n /**\n  * \\brief Construct an instance of an Extensible class\n  * \\param[in] d Pointer to the private data instance\n+ *\n+ * The private data lifetime is managed by the Extensible class, which destroys\n+ * it when the Extensible instance is destroyed.\n  */\n-Extensible::Extensible(Extensible::Private *d)\n-\t: d_(d)\n+Extensible::Extensible(std::unique_ptr<Extensible::Private> d)\n+\t: d_(std::move(d))\n {\n \t*const_cast<Extensible **>(&d_->o_) = this;\n }\n@@ -163,6 +166,10 @@ Extensible::Extensible(Extensible::Private *d)\n  * overriden _d() functions that return the correct pointer type to the\n  * corresponding derived Private class.\n  *\n+ * The lifetime of the private data is tied to the Extensible class. The caller\n+ * shall not retain any reference to the returned pointer for longer than it\n+ * holds a reference to the Extensible instance.\n+ *\n  * \\return A pointer to the private data instance\n  */\n \ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 6281e92057e4..8e99e2a96eaf 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -596,7 +596,7 @@ const std::string &Camera::id() const\n \n Camera::Camera(PipelineHandler *pipe, const std::string &id,\n \t       const std::set<Stream *> &streams)\n-\t: Extensible(new Private(pipe, id, streams))\n+\t: Extensible(std::make_unique<Private>(pipe, id, streams))\n {\n }\n \ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex 893aa6067171..fe80a46f5d20 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -258,7 +258,7 @@ void CameraManager::Private::removeCamera(Camera *camera)\n CameraManager *CameraManager::self_ = nullptr;\n \n CameraManager::CameraManager()\n-\t: Extensible(new CameraManager::Private())\n+\t: Extensible(std::make_unique<CameraManager::Private>())\n {\n \tif (self_)\n \t\tLOG(Camera, Fatal)\ndiff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\nindex 42c73134152b..b401c50efd53 100644\n--- a/src/libcamera/framebuffer.cpp\n+++ b/src/libcamera/framebuffer.cpp\n@@ -181,7 +181,8 @@ FrameBuffer::Private::Private()\n  * \\param[in] cookie Cookie\n  */\n FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)\n-\t: Extensible(new Private()), planes_(planes), cookie_(cookie)\n+\t: Extensible(std::make_unique<Private>()), planes_(planes),\n+\t  cookie_(cookie)\n {\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "01/14"
    ]
}