| Summary: | Warn on broken Qt autoconnected slots | ||
|---|---|---|---|
| Product: | [Developer tools] clazy | Reporter: | Nyall Dawson <nyall.dawson> |
| Component: | general | Assignee: | Sergio Martins <smartins> |
| Status: | RESOLVED INTENTIONAL | ||
| Severity: | wishlist | CC: | eric.lemanissier, smartins |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | All | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
Any suggestion on how to implement it ? I suppose clazy needs to look inside the generated ui file and check for matching object names. 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. (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. 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) |
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.