Bug 431186 - QAbstractItemView::entered not recognized as a signal [clazy-connect-non-signal]
Summary: QAbstractItemView::entered not recognized as a signal [clazy-connect-non-signal]
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-05 16:23 UTC by joshua.l.hertz
Modified: 2021-02-26 08:40 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
pro file (652 bytes, text/plain)
2021-01-10 16:25 UTC, joshua.l.hertz
Details
main file (183 bytes, text/plain)
2021-01-10 16:25 UTC, joshua.l.hertz
Details
mainwindow file (474 bytes, text/plain)
2021-01-10 16:26 UTC, joshua.l.hertz
Details
mainwindow header (344 bytes, text/plain)
2021-01-10 16:26 UTC, joshua.l.hertz
Details
subclass implementation; bug found here (207 bytes, text/plain)
2021-01-10 16:27 UTC, joshua.l.hertz
Details
subclass header (228 bytes, text/plain)
2021-01-10 16:28 UTC, joshua.l.hertz
Details
Clazy bug project (2.82 KB, application/x-zip-compressed)
2021-01-10 20:11 UTC, joshua.l.hertz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description joshua.l.hertz 2021-01-05 16:23:19 UTC
SUMMARY
When connecting to QAbstractItemView::entered signal, clazy doesn't recognize it as a signal.

STEPS TO REPRODUCE
1. Subclass a QTreeWidget
2. In the constructor, include something like this:
    connect(this, &QTreeWidget::entered, this, []{});
         //or//
    connect(this, &QAbstractItemView::entered, this, []{});
3. Run clazy

OBSERVED RESULT
Clazy warns that the ::entered signal as not a signal

EXPECTED RESULT
Clazy recognizes the ::entered signal as a signal and no warning is given

SOFTWARE/OS VERSIONS
Windows: 10
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 5.12.1

ADDITIONAL INFORMATION
Comment 1 Sergio Martins 2021-01-10 13:41:54 UTC
Git commit d3f6b6606b170c7daf8abdd24ac69e562e86b9b8 by Sergio Martins.
Committed on 10/01/2021 at 13:40.
Pushed by smartins into branch 'master'.

connect-non-signal: Add a testcsae for bug 431186

I can't reproduce

A  +9    -0    tests/connect-non-signal/bug431186.cpp  *
A  +0    -0    tests/connect-non-signal/bug431186.cpp.expected
M  +3    -0    tests/connect-non-signal/config.json

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


https://invent.kde.org/sdk/clazy/commit/d3f6b6606b170c7daf8abdd24ac69e562e86b9b8
Comment 2 Sergio Martins 2021-01-10 13:43:09 UTC
Do you have either precompiled headers turned on, or ccache running ?

Can you paste the complete compiler invocation ?
Comment 3 joshua.l.hertz 2021-01-10 16:25:45 UTC
Created attachment 134713 [details]
pro file
Comment 4 joshua.l.hertz 2021-01-10 16:25:59 UTC
Created attachment 134714 [details]
main file
Comment 5 joshua.l.hertz 2021-01-10 16:26:14 UTC
Created attachment 134715 [details]
mainwindow file
Comment 6 joshua.l.hertz 2021-01-10 16:26:28 UTC
Created attachment 134716 [details]
mainwindow header
Comment 7 joshua.l.hertz 2021-01-10 16:27:01 UTC
Created attachment 134717 [details]
subclass implementation; bug found here
Comment 8 joshua.l.hertz 2021-01-10 16:28:10 UTC
Created attachment 134718 [details]
subclass header
Comment 9 joshua.l.hertz 2021-01-10 16:29:17 UTC
Using Qt 5.12.1, with both MinGW 64 bit and a MinGW Static compile
Comment 10 joshua.l.hertz 2021-01-10 16:31:55 UTC
Apologies if this is not the info you need. Not consciously using precompiled headers or ccache. 

11:29:47: Running steps for project clazybugtest...
11:29:47: Starting: "C:\Qt\5.12.1\mingw73_64\bin\qmake.exe" "C:\Users\...\Files\CPP\Qt\clazybugtest\clazybugtest.pro" -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
Info: creating stash file C:\Users\...\Files\CPP\Qt\build-clazybugtest-Desktop_Qt_5_12_1_MinGW_64_bit-Debug\.qmake.stash
11:29:48: The process "C:\Qt\5.12.1\mingw73_64\bin\qmake.exe" exited normally.
11:29:48: Starting: "C:\Qt\Tools\mingw730_64\bin\mingw32-make.exe" -f "C:/Users/.../Files/CPP/Qt/build-clazybugtest-Desktop_Qt_5_12_1_MinGW_64_bit-Debug/Makefile" qmake_all
mingw32-make: Nothing to be done for 'qmake_all'.
11:29:49: The process "C:\Qt\Tools\mingw730_64\bin\mingw32-make.exe" exited normally.
11:29:49: Starting: "C:\Qt\Tools\mingw730_64\bin\mingw32-make.exe" -j4
Comment 11 Sergio Martins 2021-01-10 19:34:50 UTC
thanks

can you upload a single .zip and make sure it compiles ?

I think something went wrong with your upload, some files say:

#include "Error in " Util.relativeFilePath('C:/Users/jhertz/Dropbox (NU College of Eng'g)/Files/CPP/Qt/mainwindow.h', 'C:/Users/jhertz/Dropbox (NU College of Eng'g)/Files/CPP/Qt' + '/' + Util.path('mainwindow.cpp'))": SyntaxError: Unexpected token `identifier'"
#include "ui_mainwindow.h"
Comment 12 joshua.l.hertz 2021-01-10 20:11:38 UTC
Created attachment 134723 [details]
Clazy bug project

Hopefully this is sufficient. Apologies if not.
Comment 13 Sergio Martins 2021-01-10 20:26:36 UTC
thanks, that built fine, but doesn't show the problem

Is this something you're seeing when compiling the project with clazy = (clang+mingw+clazy plugin) or is this a warning you're seeing in QtCreator code analysis tools (which underlines the problem) ?
Comment 14 joshua.l.hertz 2021-01-10 20:52:57 UTC
Qtcreator code analysis tools, both the "realtime" analysis that underlines the text and the "Analyze > Clang-Tidy and Clazy" anlysis.
Comment 15 joshua.l.hertz 2021-01-10 21:19:36 UTC
Hmmm...I get the same "...is not a signal [clazy-connect-non-signal]" warning when connecting to all of these signals that are inherited from QAbstractItemView
    connect(this, &QTreeWidget::entered, this, &treewidg::itemEntered);
    connect(this, &QTreeWidget::pressed, this, &treewidg::itemEntered);
    connect(this, &QTreeWidget::viewportEntered, this, &treewidg::itemEntered);
    connect(this, &QTreeWidget::activated, this, &treewidg::itemEntered);
    connect(this, &QTreeWidget::clicked, this, &treewidg::itemEntered);

as well as from these signals inherited from QTreeView:
    connect(this, &QTreeWidget::collapsed, this, &treewidg::itemEntered);
    connect(this, &QTreeWidget::expanded, this, &treewidg::itemEntered);

but NOT from any of these signals inherited from QTreeWidget:
    connect(this, &QTreeWidget::itemEntered, this, &treewidg::itemEntered);
    connect(this, &QTreeWidget::itemExpanded, this, &treewidg::itemEntered);
    connect(this, &QTreeWidget::itemPressed, this, &treewidg::itemEntered);
    connect(this, &QTreeWidget::currentItemChanged, this, &treewidg::itemEntered);
    connect(this, &QTreeWidget::itemSelectionChanged, this, &treewidg::itemEntered);
Comment 16 Sergio Martins 2021-01-20 10:44:50 UTC
This is a bug in QtCreator's clazy integration, needs to be reported at https://bugs.qt.io instead
Comment 17 joshua.l.hertz 2021-01-21 13:07:18 UTC
Reported to QtCreator bugs, but:

This is reproducible outside Qt Creator. E.g. for the project in test.zip, pass -DCMAKE_EXPORT_COMPILE_COMMANDS to the cmake command line, and then run clazy-standalone with -p <build dir> on your file. You will get the same false positive as in Creator (on macOS at least; this particular example does not trigger for me on Linux, but I've seen the warning in more complex projects).
Comment 18 Sergio Martins 2021-01-21 13:54:58 UTC
Interesting, can you open the compile_commands.json, go to the line of your translation unit, and start removing compiler flags until you can't repro ?

I think there's some flag which is the culprit.

Another idea is to test clazy from  https://downloads.kdab.com/clazy/1.8/clazy_v1.8-msvc2019.zip instead of the one shipped with QtC.
Comment 19 Thierry Bastian 2021-01-25 09:06:35 UTC
I tried with 1.8 on my MacOS (built it myself) and it worked (as it did with Qt creator 4.13 before). No warnings.
Comment 20 Thierry Bastian 2021-01-25 09:10:31 UTC
interestingly, I tried clay 1.9 that I built myself and it is also fine...
Comment 21 Thierry Bastian 2021-01-25 09:47:32 UTC
hmm I tried again and now I'm getting those warnings. There must be something in the environment somewhere that is making a difference.
Comment 22 Sergio Martins 2021-02-03 14:04:10 UTC
What do we know so far, is it Windows only ?

Thierry, did you repro on macOS ?
Anyone repro on Linux ?
Comment 23 Sergio Martins 2021-02-07 14:58:28 UTC
Thierry, can you reproduce with clazy master ?
Comment 24 Eike Ziller 2021-02-24 13:36:14 UTC
I can reproduce the issue on macOS (11.2).

I managed to track this down to

Reapply d6b07989e7a9211b21ecb9b9f8bd4d237bcc453e. (2575f65c)
https://invent.kde.org/sdk/clazy/-/commit/2575f65c021a8ae18aa2de2bab4b07c8fc2b4a6b
Comment 25 Sergio Martins 2021-02-24 13:39:11 UTC
can you paste here the commands you use to compile and install clazy ?
If it's done within a QtCreator build, are there instructions I can do the same ?
Comment 26 Eike Ziller 2021-02-24 13:49:52 UTC
(In reply to Sergio Martins from comment #25)
> can you paste here the commands you use to compile and install clazy ?
> If it's done within a QtCreator build, are there instructions I can do the
> same ?

Sure.

mkdir build && cd build && cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_PREFIX_PATH=/usr/local/opt/llvm .. && cmake --build . && cmake --install .

LLVM in /usr/local/opt/llvm is from brew, version 11.1.0.
cmake version 3.19.4
ninja version 1.10.2
Xcode 12.4

I point Qt Creator to that clazy-standalone binary in the options (Analyzer > Clang Tools).
Comment 27 Sergio Martins 2021-02-24 13:54:33 UTC
thanks, I'll have a try
Comment 28 Sergio Martins 2021-02-24 23:42:16 UTC
I've finally reproduced without QtCreator. Needs the -export-fixes=foo argument to reproduce
Comment 29 Sergio Martins 2021-02-25 20:20:47 UTC
Git commit 876796fb007cd6245fda37b6035b2504fdb6ad6e by Sergio Martins.
Committed on 25/02/2021 at 20:16.
Pushed by smartins into branch '1.9'.

Fix -Wconnect-non-signal when fixits are enabled on macOS

Partially reverts d6b07989e7a921. The fixit for copyable-polymorphic
is now guarded by an opt-in env variable. I think it's not worth the slow
down anyway, and since it causes regressions for connect-non-signal,
disable it by default

M  +9    -2    src/AccessSpecifierManager.cpp
M  +1    -0    src/AccessSpecifierManager.h

https://invent.kde.org/sdk/clazy/commit/876796fb007cd6245fda37b6035b2504fdb6ad6e
Comment 30 Eike Ziller 2021-02-26 08:40:11 UTC
Just for the record: clazy-incorrect-emit was also affected (and is now fixed).