View Full Version : Static connection analysis tool?

22nd September 2011, 01:34
I am wondering if there is a tool for static analysis of SIGNAL-SLOT connections in source code. When using Visual Studio to run an app in debug mode, Qt will report when connect() is called with non-existent SIGNAL or SLOT methods. In general, however, these message are output only when the connect() code is executed, so unless you exercise all parts of the UI, you may not see all of the incomplete connections in the code. When making changes to code that involve renaming signals, slots, or changes to their signatures, it is often easy to miss something that needs to be fixed after the change.

Is there a tool that will statically analyze source code and identify these dangling connections?

I am aware of Conan (http://qt-apps.org/content/show.php/Conan+-+Connection+analyzer+for+Qt?content=108330), but this is a run-time analyzer.

22nd September 2011, 21:58
In Qt 5 it is likely that you will be able to do connections using the function pointers:

connect(sender, &Sender::someSignal, receiver, &Receiver::someSlot)

However, the precise syntax hasn't been definitively decided on. This will give you compile-time checking.

25th September 2011, 00:17
Thanks. That will be very nice when that happens. Slots and signals are one of the best features of Qt, but also the hardest to maintain.

25th September 2011, 09:10
Be aware some slots or signals are generated on the fly during runtime so such errors may not be possible to be deteremined in some cases.