Bug 385475 - Warn on broken Qt autoconnected slots
Summary: Warn on broken Qt autoconnected slots
Status: RESOLVED INTENTIONAL
Alias: None
Product: clazy
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other All
: NOR wishlist
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-07 22:37 UTC by Nyall Dawson
Modified: 2017-12-15 17:01 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nyall Dawson 2017-10-07 22:37:22 UTC
I'm working on a large codebase with lots of legacy code, and lots of the older code relied heavily on autoconnect Qt slots ("on_buttonDoSomething_clicked()").

These are extremely fragile and make refactoring code hard. I'd love to see a clazy warning for suspected auto connecting slots which are broken, due to missing/renamed widgets.
Comment 1 Sergio Martins 2017-10-08 10:42:29 UTC
Any suggestion on how to implement it ?

I suppose clazy needs to look inside the generated ui file and check for matching object names.
Comment 2 Nyall Dawson 2017-10-08 22:32:21 UTC
I'd do it in a much cruder way - look for slots which match the regex "on_(.+)_(.+)", where the first group doesn't match a QObject member or the second group doesn't match a signal for the type of that member.

Then we'd catch both errors in the member name AND in the signal name.
Comment 3 eric.lemanissier 2017-10-16 09:09:49 UTC
(In reply to Nyall Dawson from comment #2)
> I'd do it in a much cruder way - look for slots which match the regex
> "on_(.+)_(.+)", where the first group doesn't match a QObject member or the
> second group doesn't match a signal for the type of that member.
> 
> Then we'd catch both errors in the member name AND in the signal name.

Matching the first group with QObject member won't work in a lot of cases, as  the member can actually be a member of the ui member, depending on qt creator's Qt Class Generation setting.
Comment 4 Sergio Martins 2017-12-15 17:01:02 UTC
clazy should warn for all auto connected slots, as it's a very awful feature, regardless if they are broken or working.

That's implemented in #385476 (connect-by-name)