Bug 355593 - Do not fix connects to static member functions with -fix-old-style-connect
Summary: Do not fix connects to static member functions with -fix-old-style-connect
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-19 14:56 UTC by Tobias Hunger
Modified: 2015-11-20 19:18 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Testcase in a more convenient form (503 bytes, application/gzip)
2015-11-19 15:06 UTC, Tobias Hunger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Hunger 2015-11-19 14:56:59 UTC
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*)));
}
Comment 1 Sergio Martins 2015-11-19 15:01:13 UTC
Lets leave the disconnect alone, but the connect is fine, no ?
Comment 2 Tobias Hunger 2015-11-19 15:06:24 UTC
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.
Comment 3 Tobias Hunger 2015-11-19 15:08:19 UTC
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.
Comment 4 Sergio Martins 2015-11-20 19:18:53 UTC
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