Bug 376137

Summary: Internal error caused by overloaded signal
Product: [Developer tools] clazy Reporter: Daniel Pfeifer <daniel>
Component: generalAssignee: Sergio Martins <smartins>
Status: RESOLVED FIXED    
Severity: crash CC: smartins
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Daniel Pfeifer 2017-02-07 15:00:07 UTC
Here is the code to reproduce it:

#include <QObject>

class Foo : public QObject
{
    Q_OBJECT

public:
    Foo()
    {
        connect(this, static_cast<void (Foo::*)(int)>(&Foo::bar), [](int) {});
        connect(this, qOverload<float>(&Foo::bar), [](float) {});
    }

Q_SIGNALS:
    void bar(int);
    void bar(float);
};


Currently, both connect calls produce "internal error: couldn't find method from pmf connect".

Once this is fixed, you may think about adding a checker that flags the use of static_cast in signal connections and recommends to use qOverload.  Thanks!
Comment 1 Sergio Martins 2017-02-11 19:56:53 UTC
Git commit e098fe057b9984df3eb630513e90eea0fa471d2a by Sergio Martins.
Committed on 11/02/2017 at 19:56.
Pushed by smartins into branch '1.1'.

connect-non-signal: Add failign unit test

A  +16   -0    tests/connect-non-signal/bug376137.cpp     [License: UNKNOWN]  *
M  +5    -0    tests/connect-non-signal/config.json

The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.


https://commits.kde.org/clazy/e098fe057b9984df3eb630513e90eea0fa471d2a
Comment 2 Sergio Martins 2017-02-12 01:11:30 UTC
Git commit a261683a0fc66f07a14a256a3aac859767e297be by Sergio Martins.
Committed on 12/02/2017 at 01:10.
Pushed by smartins into branch '1.1'.

connect-non-signal: Don't fail to detect signals wrapped with a static-cast

M  +2    -0    src/QtUtils.cpp
M  +1    -2    tests/connect-non-signal/bug376137.cpp
A  +0    -0    tests/connect-non-signal/bug376137.cpp.expected
M  +0    -1    tests/connect-non-signal/config.json

https://commits.kde.org/clazy/a261683a0fc66f07a14a256a3aac859767e297be