| Summary: | Do not fix connects to static member functions with -fix-old-style-connect | ||
|---|---|---|---|
| Product: | [Developer tools] clazy | Reporter: | Tobias Hunger <tobias.hunger> |
| Component: | general | Assignee: | Sergio Martins <smartins> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | smartins |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | http://commits.kde.org/clazy/70d3f22d0c9039dad8e61bcc0138e66fab879708 | Version Fixed/Implemented In: | |
| Sentry Crash Report: | |||
| Attachments: | Testcase in a more convenient form | ||
Lets leave the disconnect alone, but the connect is fine, no ? Created attachment 95602 [details]
Testcase in a more convenient form
Basically the same test case as found inline, but with a .pro-file and without warnings and build errors.
I think the connect is implicitly converted into a lambda, which can't be disconnected later. So to be safe you should leave both the connect and disconnect alone. Git commit 70d3f22d0c9039dad8e61bcc0138e66fab879708 by Sergio Martins.
Committed on 20/11/2015 at 19:18.
Pushed by smartins into branch 'master'.
old-style-connect: Don't fix connects to static slots
Only connect works, disconnect doesn't build.
And you can't use old-style disconnect to break a new-style connect.
The only solution is to not apply fixits to {dis}connects to static slots.
M +3 -0 checks/oldstyleconnect.cpp
M +23 -0 tests/old-style-connect/main.cpp
M +2 -0 tests/old-style-connect/test.expected
http://commits.kde.org/clazy/70d3f22d0c9039dad8e61bcc0138e66fab879708
|
Please do not fix old style connects to static member functions. The connect will actually compile, but the disconnect won't, so it is IMHO better to not touch these. E.g.: The following connect/disconnect should be left alone: #include <QObject> class TestClass : public QObject { public slots: TestClass(QObject *parent = nullptr) : QObject(parent) { } static void test(QObject *obj) { Q_UNUSED(obj); } }; int main(int argc, char** argv) { auto test = new TestClass; connect(test, SIGNAL(destroyed(QObject*)), test, SLOT(test(QObject*))); disconnect(test, SIGNAL(destroyed(QObject*)), test, SLOT(test(QObject*))); }