Patch Detail
Show a patch.
GET /api/patches/276/?format=api
{ "id": 276, "url": "https://patchwork.libcamera.org/api/patches/276/?format=api", "web_url": "https://patchwork.libcamera.org/patch/276/", "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": "<20190118232617.14631-3-laurent.pinchart@ideasonboard.com>", "date": "2019-01-18T23:26:15", "name": "[libcamera-devel,v2,2/4] libcamera: camera_manager: Use std::unique_ptr to store event dispatcher", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "074debb17338150338d3ad60f1fcfb0640e781fb", "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/276/mbox/", "series": [ { "id": 94, "url": "https://patchwork.libcamera.org/api/series/94/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=94", "date": "2019-01-18T23:26:13", "name": "Object lifetime management", "version": 2, "mbox": "https://patchwork.libcamera.org/series/94/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/276/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/276/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DD7F560C78\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 19 Jan 2019 00:26:21 +0100 (CET)", "from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5353253E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 19 Jan 2019 00:26:21 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1547853981;\n\tbh=9Djyc7v/dOhluNfzsyGTNJdHSRrI7VLC07N9DnanbEo=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=KnUkKjC4eJzkzaCSDdS78rHz4WW6eJ+XPtKVr9Y9khmgJJnly413mz7xcy8BY532U\n\tjX59VynCaoKaMsM7hw+rksCgSitsRNRnMredVJufGToPL1z/BcyX6InSyEQjBYduqM\n\tKsHf4FDWdtuPFLUxunhBcgmwSOPmJgMaLSVhtqTs=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 19 Jan 2019 01:26:15 +0200", "Message-Id": "<20190118232617.14631-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.2", "In-Reply-To": "<20190118232617.14631-1-laurent.pinchart@ideasonboard.com>", "References": "<20190118232617.14631-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 2/4] libcamera: camera_manager: Use\n\tstd::unique_ptr to store event dispatcher", "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, 18 Jan 2019 23:26:22 -0000" }, "content": "The CameraManager takes ownership of the dispatcher passed to the\nsetEventDispatcher() function. Enforces this by using std::unique_ptr<>.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nChanges since v1:\n\n- Use make_unique<> in CameraManager::setEventDispatcher()\n---\n include/libcamera/camera_manager.h | 4 ++--\n src/libcamera/camera_manager.cpp | 12 +++++++-----\n 2 files changed, 9 insertions(+), 7 deletions(-)", "diff": "diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h\nindex 6cfcba3c3933..b82a8ce95b9f 100644\n--- a/include/libcamera/camera_manager.h\n+++ b/include/libcamera/camera_manager.h\n@@ -29,7 +29,7 @@ public:\n \n \tstatic CameraManager *instance();\n \n-\tvoid setEventDispatcher(EventDispatcher *dispatcher);\n+\tvoid setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher);\n \tEventDispatcher *eventDispatcher();\n \n private:\n@@ -41,7 +41,7 @@ private:\n \tstd::unique_ptr<DeviceEnumerator> enumerator_;\n \tstd::vector<PipelineHandler *> pipes_;\n \n-\tEventDispatcher *dispatcher_;\n+\tstd::unique_ptr<EventDispatcher> dispatcher_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex 9f554be57e33..1430bb0d75a5 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -12,6 +12,7 @@\n #include \"event_dispatcher_poll.h\"\n #include \"log.h\"\n #include \"pipeline_handler.h\"\n+#include \"utils.h\"\n \n /**\n * \\file camera_manager.h\n@@ -58,7 +59,6 @@ CameraManager::CameraManager()\n \n CameraManager::~CameraManager()\n {\n-\tdelete dispatcher_;\n }\n \n /**\n@@ -209,14 +209,14 @@ CameraManager *CameraManager::instance()\n * The CameraManager takes ownership of the event dispatcher and will delete it\n * when the application terminates.\n */\n-void CameraManager::setEventDispatcher(EventDispatcher *dispatcher)\n+void CameraManager::setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher)\n {\n \tif (dispatcher_) {\n \t\tLOG(Warning) << \"Event dispatcher is already set\";\n \t\treturn;\n \t}\n \n-\tdispatcher_ = dispatcher;\n+\tdispatcher_ = std::move(dispatcher);\n }\n \n /**\n@@ -226,14 +226,16 @@ void CameraManager::setEventDispatcher(EventDispatcher *dispatcher)\n * If no dispatcher has been set, a default poll-based implementation is created\n * and returned, and no custom event dispatcher may be installed anymore.\n *\n+ * The returned event dispatcher is valid until the camera manager is destroyed.\n+ *\n * \\return Pointer to the event dispatcher\n */\n EventDispatcher *CameraManager::eventDispatcher()\n {\n \tif (!dispatcher_)\n-\t\tdispatcher_ = new EventDispatcherPoll();\n+\t\tdispatcher_ = utils::make_unique<EventDispatcherPoll>();\n \n-\treturn dispatcher_;\n+\treturn dispatcher_.get();\n }\n \n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "v2", "2/4" ] }