Show a patch.

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

{
    "id": 17248,
    "url": "https://patchwork.libcamera.org/api/patches/17248/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17248/",
    "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": "<20220830030615.29089-1-laurent.pinchart@ideasonboard.com>",
    "date": "2022-08-30T03:06:15",
    "name": "[libcamera-devel] libcamera: base: signal: Disable connect() for functor if args mismatch",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "730c2a4636e901c7b6dc7cc954e8adbe51534512",
    "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/17248/mbox/",
    "series": [
        {
            "id": 3451,
            "url": "https://patchwork.libcamera.org/api/series/3451/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3451",
            "date": "2022-08-30T03:06:15",
            "name": "[libcamera-devel] libcamera: base: signal: Disable connect() for functor if args mismatch",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3451/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17248/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17248/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 4D361C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Aug 2022 03:06:27 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8E24C61FC1;\n\tTue, 30 Aug 2022 05:06:26 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5D8F2603E0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Aug 2022 05:06:25 +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 A139C4A8;\n\tTue, 30 Aug 2022 05:06:24 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661828786;\n\tbh=AFlfpybCwUKEMj/4KfEi4jsLzT1hkHhJMmsTIIMRX34=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=4GRU7xCyJ/iN4mx2ZfvjK74Lh7aa1fzmerUnn6Y4Mbl/rfOV8oDyW6QoRUC/GCFXi\n\tN8xJPAnYuAdIUgWBcDZHJAukxzhVflXy0rUv87a37Ar0P98rek4tA5EOok5UzJJOAt\n\tubAa9lBjsBiBL4pLCEXpYWCwsZitS8I1DXZwu4ptLpd2L31L5mo2dGVaI4gzQPti0q\n\tD82vgzqo5PzhS85Oy398tNaIfeEu9x5+HFSzVJPS6A1w8MTo5pZ0Gt0/Kfo6SREX8j\n\th2bWmW+kUzwag6xcpi6/ZAaZS/N37m3qF3bvTlWBrlPVptCAO8YBRxPdrfJaCWSinf\n\t07QXipu4Gr6kw==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661828784;\n\tbh=AFlfpybCwUKEMj/4KfEi4jsLzT1hkHhJMmsTIIMRX34=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=Pyu737Wrb/fAg4wVL+SQwpCz+vVm/JquotlsiC6/YY3mvh8Idj+9ey1yUtVBI5xSc\n\t5JprolfeE1UrdWl6iHsxMqY96IiOiLedId4Hq/+QeCOEEp1ZxbWvQIWNllxpMIhDxw\n\tB0w/TRR7B+2Gi0jlcGiE1DxmcLqQJwuJmoHdx+4A="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Pyu737Wr\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 30 Aug 2022 06:06:15 +0300",
        "Message-Id": "<20220830030615.29089-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.35.1",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] libcamera: base: signal: Disable\n\tconnect() for functor if args mismatch",
        "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": "If a pointer-to-member is passed to the Signal::connect() function with\narguments that don't match the Signal type, the pointer-to-member\nversion of connect() will not match during template argument resolution,\nbut the functor version will. This results in a compilation error in the\nBoundMethodFunctor class, due to the pointer-to-member not being a\nfunctor and thus not being callable directly. The error messages are\nquite cryptic. With the following error applied,",
    "diff": "diff --git a/test/signal.cpp b/test/signal.cpp\nindex 5c6b304dac0b..6dd11ac45313 100644\n--- a/test/signal.cpp\n+++ b/test/signal.cpp\n@@ -107,6 +107,7 @@ protected:\n \t\t/* Test signal emission and reception. */\n \t\tcalled_ = false;\n \t\tsignalVoid_.connect(this, &SignalTest::slotVoid);\n+\t\tsignalVoid_.connect(this, &SignalTest::slotInteger1);\n \t\tsignalVoid_.emit();\n\n \t\tif (!called_) {\n\ngcc outputs\n\n../../include/libcamera/base/bound_method.h: In instantiation of ‘R libcamera::BoundMethodFunctor<T, R, Func, Args>::activate(Args ..., bool) [with T = SignalTest; R = void; Func = void (SignalTest::*)(int); Args = {}]’:\n../../include/libcamera/base/bound_method.h:143:4:   required from here\n../../include/libcamera/base/bound_method.h:146:37: error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘((libcamera::BoundMethodFunctor<SignalTest, void, void (SignalTest::*)(int)>*)this)->libcamera::BoundMethodFunctor<SignalTest, void, void (SignalTest::*)(int)>::func_ (...)’, e.g. ‘(... ->* ((libcamera::BoundMethodFunctor<SignalTest, void, void (SignalTes\nt::*)(int)>*)this)->libcamera::BoundMethodFunctor<SignalTest, void, void (SignalTest::*)(int)>::func_) (...)’\n  146 |                         return func_(args...);\n      |                                ~~~~~^~~~~~~~~\n\nand clang isn't much better:\n\n../../include/libcamera/base/bound_method.h:146:11: error: called object type 'void (SignalTest::*)(int)' is not a function or function pointer\n                        return func_(args...);\n                               ^~~~~\n../../include/libcamera/base/bound_method.h:137:2: note: in instantiation of member function 'libcamera::BoundMethodFunctor<SignalTest, void, void (SignalTest::*)(int)>::activate' requested here\n        BoundMethodFunctor(T *obj, Object *object, Func func,\n        ^\n../../include/libcamera/base/signal.h:80:27: note: in instantiation of member function 'libcamera::BoundMethodFunctor<SignalTest, void, void (SignalTest::*)(int)>::BoundMethodFunctor' requested here\n                SignalBase::connect(new BoundMethodFunctor<T, void, Func, Args...>(obj, nullptr, func));\n                                        ^\n../../test/signal.cpp:110:15: note: in instantiation of function template specialization 'libcamera::Signal<>::connect<SignalTest, void (SignalTest::*)(int), nullptr>' requested here\n                signalVoid_.connect(this, &SignalTest::slotInteger1);\n                            ^\n\nImprove error reporting by disabling the functor version of connect()\nwhen the Func argument isn't invocable with the Signal arguments. gcc\nwill then complain with\n\n../../test/signal.cpp:110:36: error: no matching function for call to ‘libcamera::Signal<>::connect(SignalTest*, void (SignalTest::*)(int))’\n  110 |                 signalVoid_.connect(this, &SignalTest::slotInteger1);\n      |                 ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nand clang with\n\n../../test/signal.cpp:110:15: error: no matching member function for call to 'connect'\n                signalVoid_.connect(this, &SignalTest::slotInteger1);\n                ~~~~~~~~~~~~^~~~~~~\n\nwhich are more readable.\n\nThis change requires usage of std::is_invocable<>, which is only\navailable starting in C++17. This is fine for usage of the Signal class\nwithin libcamera, as the project is compiled with C++17, but we try to\nkeep the public API compatible C++14. Condition the additional checks\nbased on the C++ version.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/base/signal.h | 12 ++++++++++--\n 1 file changed, 10 insertions(+), 2 deletions(-)\n\ndiff --git a/include/libcamera/base/signal.h b/include/libcamera/base/signal.h\nindex efb591bc5073..841e4b4ca15c 100644\n--- a/include/libcamera/base/signal.h\n+++ b/include/libcamera/base/signal.h\n@@ -63,7 +63,11 @@ public:\n \n #ifndef __DOXYGEN__\n \ttemplate<typename T, typename Func,\n-\t\t std::enable_if_t<std::is_base_of<Object, T>::value> * = nullptr>\n+\t\t std::enable_if_t<std::is_base_of<Object, T>::value\n+#if __cplusplus >= 201703L\n+\t\t\t\t  && std::is_invocable_v<Func, Args...>\n+#endif\n+\t\t\t\t  > * = nullptr>\n \tvoid connect(T *obj, Func func, ConnectionType type = ConnectionTypeAuto)\n \t{\n \t\tObject *object = static_cast<Object *>(obj);\n@@ -71,7 +75,11 @@ public:\n \t}\n \n \ttemplate<typename T, typename Func,\n-\t\t std::enable_if_t<!std::is_base_of<Object, T>::value> * = nullptr>\n+\t\t std::enable_if_t<!std::is_base_of<Object, T>::value\n+#if __cplusplus >= 201703L\n+\t\t\t\t  && std::is_invocable_v<Func, Args...>\n+#endif\n+\t\t\t\t  > * = nullptr>\n #else\n \ttemplate<typename T, typename Func>\n #endif\n",
    "prefixes": [
        "libcamera-devel"
    ]
}