Patch Detail
Show a patch.
GET /api/patches/19569/?format=api
{ "id": 19569, "url": "https://patchwork.libcamera.org/api/patches/19569/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19569/", "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": "<20240229165753.154936-1-stefan.klug@ideasonboard.com>", "date": "2024-02-29T16:57:53", "name": "libcamera: controls: Add overwriteExisting parameter to ControlList::merge", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "78973752480e1fffe2f5b3f1acc00a523c8f9099", "submitter": { "id": 184, "url": "https://patchwork.libcamera.org/api/people/184/?format=api", "name": "Stefan Klug", "email": "stefan.klug@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19569/mbox/", "series": [ { "id": 4193, "url": "https://patchwork.libcamera.org/api/series/4193/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4193", "date": "2024-02-29T16:57:53", "name": "libcamera: controls: Add overwriteExisting parameter to ControlList::merge", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4193/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19569/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19569/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 9821ABE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 29 Feb 2024 16:58:12 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0199A6286C;\n\tThu, 29 Feb 2024 17:58:12 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 02F9261C96\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 29 Feb 2024 17:58:10 +0100 (CET)", "from jasper.fritz.box (unknown\n\t[IPv6:2a00:6020:448c:6c00:69c9:7315:683e:a8b])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4948DD4A;\n\tThu, 29 Feb 2024 17:57:57 +0100 (CET)" ], "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=\"JcUIgVFb\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1709225877;\n\tbh=garPSutDujJXALhkhrWtBPRSlTBRaN81I895RmsaSvk=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=JcUIgVFbZGymhd4kaOW/E1FYTE/RXdVYuwCNn4UlEZUFeLGVqsbR6MYhyJo1u1Ooq\n\tEJtg5Tkg/86J6MxorXz74mRC0IL5OQYPwtBKTuj4xdbpE7LKx3yNdNuMSrAVpawRAM\n\tFoWJRWCh6GXMRhJeeopShb+vt00jV+vhQb1/9QHg=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH] libcamera: controls: Add overwriteExisting parameter to\n\tControlList::merge", "Date": "Thu, 29 Feb 2024 17:57:53 +0100", "Message-Id": "<20240229165753.154936-1-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.40.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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": "This is useful in many cases although not included in the stl.\n\nA typical usecase would be:\nContolList controls = getDefaults()\ncontrols.merge(someSpecialValues, true)\n...\n\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n\nHey,\n\nthis is my first email patch - hurray :-)\n\nCheers,\nStefan\n\n include/libcamera/controls.h | 2 +-\n src/libcamera/controls.cpp | 9 ++++++---\n 2 files changed, 7 insertions(+), 4 deletions(-)", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex cf942055..0bf778d8 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -368,7 +368,7 @@ public:\n \tstd::size_t size() const { return controls_.size(); }\n \n \tvoid clear() { controls_.clear(); }\n-\tvoid merge(const ControlList &source);\n+\tvoid merge(const ControlList &source, bool overwriteExisting = false);\n \n \tbool contains(unsigned int id) const;\n \ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex b808116c..8ef29a96 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -910,10 +910,13 @@ ControlList::ControlList(const ControlInfoMap &infoMap,\n /**\n * \\brief Merge the \\a source into the ControlList\n * \\param[in] source The ControlList to merge into this object\n+ * \\param[in] overwriteExisting Control if existing elements in *this shall be\n+ * overwritten\n *\n * Merging two control lists copies elements from the \\a source and inserts\n * them in *this. If the \\a source contains elements whose key is already\n- * present in *this, then those elements are not overwritten.\n+ * present in *this, then those elements are only overwritten if\n+ * overwriteExisting is true.\n *\n * Only control lists created from the same ControlIdMap or ControlInfoMap may\n * be merged. Attempting to do otherwise results in undefined behaviour.\n@@ -921,7 +924,7 @@ ControlList::ControlList(const ControlInfoMap &infoMap,\n * \\todo Reimplement or implement an overloaded version which internally uses\n * std::unordered_map::merge() and accepts a non-const argument.\n */\n-void ControlList::merge(const ControlList &source)\n+void ControlList::merge(const ControlList &source, bool overwriteExisting)\n {\n \t/**\n \t * \\todo ASSERT that the current and source ControlList are derived\n@@ -936,7 +939,7 @@ void ControlList::merge(const ControlList &source)\n \t */\n \n \tfor (const auto &ctrl : source) {\n-\t\tif (contains(ctrl.first)) {\n+\t\tif (!overwriteExisting && contains(ctrl.first)) {\n \t\t\tconst ControlId *id = idmap_->at(ctrl.first);\n \t\t\tLOG(Controls, Warning)\n \t\t\t\t<< \"Control \" << id->name() << \" not overwritten\";\n", "prefixes": [] }