Show a patch.

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

{
    "id": 392,
    "url": "https://patchwork.libcamera.org/api/patches/392/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/392/",
    "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": "<20190125170400.24821-6-jacopo@jmondi.org>",
    "date": "2019-01-25T17:04:00",
    "name": "[libcamera-devel,5/5] libcamera: pipeline: Refuse to substitute camera data",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "a815ab53f341b0895cfb3db52a277b1ae5226277",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/392/mbox/",
    "series": [
        {
            "id": 133,
            "url": "https://patchwork.libcamera.org/api/series/133/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=133",
            "date": "2019-01-25T17:03:55",
            "name": "libcamera: camera data: Address review comments",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/133/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/392/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/392/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 631E160C82\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jan 2019 18:04:13 +0100 (CET)",
            "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id 00A1B200004;\n\tFri, 25 Jan 2019 17:04:12 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 25 Jan 2019 18:04:00 +0100",
        "Message-Id": "<20190125170400.24821-6-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190125170400.24821-1-jacopo@jmondi.org>",
        "References": "<20190125170400.24821-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 5/5] libcamera: pipeline: Refuse to\n\tsubstitute camera data",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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>",
        "X-List-Received-Date": "Fri, 25 Jan 2019 17:04:14 -0000"
    },
    "content": "Once a pipeline-specific data has been associated with a camera, refuse\nto update it in order to avoid invalidating the previously set\nreference, which might still be owned by the caller.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/pipeline_handler.h |  2 +-\n src/libcamera/pipeline_handler.cpp       | 23 ++++++++++++++---------\n 2 files changed, 15 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\nindex ca77a40..01a0f0b 100644\n--- a/src/libcamera/include/pipeline_handler.h\n+++ b/src/libcamera/include/pipeline_handler.h\n@@ -47,7 +47,7 @@ protected:\n \tvoid hotplugMediaDevice(MediaDevice *media);\n \n \tCameraData *cameraData(const Camera *camera);\n-\tvoid setCameraData(const Camera *camera, std::unique_ptr<CameraData> data);\n+\tint setCameraData(const Camera *camera, std::unique_ptr<CameraData> data);\n \n private:\n \tvirtual void disconnect();\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex dc55f8f..7e927a7 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -212,21 +212,26 @@ CameraData *PipelineHandler::cameraData(const Camera *camera)\n  * information with \\a camera. Ownership of \\a data is transferred to\n  * the PipelineHandler.\n  *\n- * If pipeline-specific data has already been associated with the camera by a\n- * previous call to this method, is it replaced by \\a data and the previous data\n- * are deleted, rendering all references to them invalid.\n+ * Once pipeline-specific data has already been associated with the camera\n+ * by a previous call to this method it cannot be changed later on.\n  *\n  * The data can be retrieved by pipeline handlers using the cameraData() method.\n+ *\n+ * \\return 0 on success, or a negative error code if camera specific data have\n+ * already been set\n  */\n-void PipelineHandler::setCameraData(const Camera *camera,\n-\t\t\t\t    std::unique_ptr<CameraData> data)\n+int PipelineHandler::setCameraData(const Camera *camera,\n+\t\t\t\t   std::unique_ptr<CameraData> data)\n {\n-\tif (cameraData_.count(camera))\n-\t\tLOG(Pipeline, Debug)\n-\t\t\t<< \"Replacing data associated with \"\n-\t\t\t<< camera->name();\n+\tif (cameraData_.find(camera) != cameraData_.end()) {\n+\t\tLOG(Pipeline, Error)\n+\t\t\t<< \"Replacing data associated with a camera is forbidden \";\n+\t\treturn -EINVAL;\n+\t}\n \n \tcameraData_[camera] = std::move(data);\n+\n+\treturn 0;\n }\n \n /**\n",
    "prefixes": [
        "libcamera-devel",
        "5/5"
    ]
}