Show a patch.

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

{
    "id": 17517,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/17517/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17517/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20221003212128.32429-8-laurent.pinchart@ideasonboard.com>",
    "date": "2022-10-03T21:21:27",
    "name": "[libcamera-devel,7/8] libcamera: pipeline_handler: Return unique_ptr from createInstance",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "059c5e1c07c1566c0777f24c066b31b8eeb3f4c3",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17517/mbox/",
    "series": [
        {
            "id": 3528,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3528/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3528",
            "date": "2022-10-03T21:21:20",
            "name": "libcamera: Use class templates for auto-registration",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3528/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17517/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17517/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 1971ABD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Oct 2022 21:21:44 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C42F860A82;\n\tMon,  3 Oct 2022 23:21:43 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 239C660A7C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Oct 2022 23:21:42 +0200 (CEST)",
            "from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A50BA519\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Oct 2022 23:21:41 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664832103;\n\tbh=k/1FbOie6DtkP1kevsnc+h35qGdJPDCcnLW792JXDGo=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=DAmzqw7ErDYeUdHFz9iVPFPHA3WTBEnuAG+LL/C3sfl2mbLh11gfUbHXD2eJNjfyZ\n\tu7kVbToWJ9R9JXmMMCc/WrxUVagg5Eefn0h00pj3nPrXGJ7T6RwiXDCQ/ws7vaIwZT\n\t8TdDCW/SRfABsW25ybedz/j2e1mf1DGQ8ZK0Vtn6wYhr+4vbviNUEb7J+Q3jEB9M/U\n\tRihcHKj61mM8gi+pthAXZmxn6jiU5uPUZ/jsOs4Nq6XJs/egynKsHu+laCPYkr+DkL\n\tlJ+zhbkyR8tF8TZpCAkxnMBKTuQI18NejDER101D7iq98c25fiydBI8+P/ig469zp2\n\tOasAxHuy1shsA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1664832101;\n\tbh=k/1FbOie6DtkP1kevsnc+h35qGdJPDCcnLW792JXDGo=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=TCgBl5/m15Y/rX1NlzcO+EIBMOGbuYVH6/MGYuLyhCSExSmggPG8uoLqqcfLNpKS/\n\tmGYzwNJNODu20J02Pl64dtkMlMpY1HlKVfe83uNlOLfTpH8ynNPhyNKKGdakA16QQd\n\t+VubniA0jeQMBnIDz0FTpW9iroV/m/7JUkcLYSBs="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"TCgBl5/m\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  4 Oct 2022 00:21:27 +0300",
        "Message-Id": "<20221003212128.32429-8-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.35.1",
        "In-Reply-To": "<20221003212128.32429-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20221003212128.32429-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 7/8] libcamera: pipeline_handler: Return\n\tunique_ptr from createInstance",
        "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>",
        "From": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Avoid naked pointer with memory allocation by returning a unique_ptr\nfrom PipelineHandlerFactory::createInstance(), in order to increase\nmemory allocation safety.\n\nThis allows iterating over factories in the CameraManager and unit tests\nusing const pointers.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/pipeline_handler.h | 8 +++++---\n src/libcamera/camera_manager.cpp              | 4 ++--\n src/libcamera/pipeline_handler.cpp            | 8 ++++----\n test/ipa/ipa_interface_test.cpp               | 4 ++--\n 4 files changed, 13 insertions(+), 11 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex ebbdf2aa391f..ad74dc823290 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -113,7 +113,8 @@ public:\n private:\n \tstatic void registerType(PipelineHandlerFactory *factory);\n \n-\tvirtual PipelineHandler *createInstance(CameraManager *manager) const = 0;\n+\tvirtual std::unique_ptr<PipelineHandler>\n+\tcreateInstance(CameraManager *manager) const = 0;\n \n \tstd::string name_;\n };\n@@ -125,9 +126,10 @@ public:\t\t\t\t\t\t\t\t\t\\\n \thandler##Factory() : PipelineHandlerFactory(#handler) {}\t\\\n \t\t\t\t\t\t\t\t\t\\\n private:\t\t\t\t\t\t\t\t\\\n-\tPipelineHandler *createInstance(CameraManager *manager) const\t\\\n+\tstd::unique_ptr<PipelineHandler>\t\t\t\t\\\n+\tcreateInstance(CameraManager *manager) const\t\t\t\\\n \t{\t\t\t\t\t\t\t\t\\\n-\t\treturn new handler(manager);\t\t\t\t\\\n+\t\treturn std::make_unique<handler>(manager);\t\t\\\n \t}\t\t\t\t\t\t\t\t\\\n };\t\t\t\t\t\t\t\t\t\\\n static handler##Factory global_##handler##Factory;\ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex 7ff4bc6fd019..2c3f2d86c469 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -142,10 +142,10 @@ void CameraManager::Private::createPipelineHandlers()\n \t * file and only fallback on all handlers if there is no\n \t * configuration file.\n \t */\n-\tstd::vector<PipelineHandlerFactory *> &factories =\n+\tconst std::vector<PipelineHandlerFactory *> &factories =\n \t\tPipelineHandlerFactory::factories();\n \n-\tfor (PipelineHandlerFactory *factory : factories) {\n+\tfor (const PipelineHandlerFactory *factory : factories) {\n \t\tLOG(Camera, Debug)\n \t\t\t<< \"Found registered pipeline handler '\"\n \t\t\t<< factory->name() << \"'\";\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 4470e9041e8e..488dd8d32cdf 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -678,9 +678,9 @@ PipelineHandlerFactory::PipelineHandlerFactory(const char *name)\n  */\n std::shared_ptr<PipelineHandler> PipelineHandlerFactory::create(CameraManager *manager) const\n {\n-\tPipelineHandler *handler = createInstance(manager);\n+\tstd::unique_ptr<PipelineHandler> handler = createInstance(manager);\n \thandler->name_ = name_.c_str();\n-\treturn std::shared_ptr<PipelineHandler>(handler);\n+\treturn std::shared_ptr<PipelineHandler>(std::move(handler));\n }\n \n /**\n@@ -727,8 +727,8 @@ std::vector<PipelineHandlerFactory *> &PipelineHandlerFactory::factories()\n  * macro. It creates a pipeline handler instance associated with the camera\n  * \\a manager.\n  *\n- * \\return a pointer to a newly constructed instance of the PipelineHandler\n- * subclass corresponding to the factory\n+ * \\return A unique pointer to a newly constructed instance of the\n+ * PipelineHandler subclass corresponding to the factory\n  */\n \n /**\ndiff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\nindex 3c0df843ea61..a629abc28da7 100644\n--- a/test/ipa/ipa_interface_test.cpp\n+++ b/test/ipa/ipa_interface_test.cpp\n@@ -52,9 +52,9 @@ protected:\n \t\tipaManager_ = make_unique<IPAManager>();\n \n \t\t/* Create a pipeline handler for vimc. */\n-\t\tstd::vector<PipelineHandlerFactory *> &factories =\n+\t\tconst std::vector<PipelineHandlerFactory *> &factories =\n \t\t\tPipelineHandlerFactory::factories();\n-\t\tfor (PipelineHandlerFactory *factory : factories) {\n+\t\tfor (const PipelineHandlerFactory *factory : factories) {\n \t\t\tif (factory->name() == \"PipelineHandlerVimc\") {\n \t\t\t\tpipe_ = factory->create(nullptr);\n \t\t\t\tbreak;\n",
    "prefixes": [
        "libcamera-devel",
        "7/8"
    ]
}