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.
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)