Conan - Connection Analyzer for Qt

1.0.2

Conan.jpg

The Conan widget 'conan::ConanWidget'

Conan

Conan is a C++ library that provides run-time introspection of object hierarchies, object inheritance, signal/slot connections, and signal emissions.

Conan contains a single widget (conan::ConanWidget) that provides the following functionality:

Conan has been used to identify multiple duplicate connections in the source code of Qt!

Contact - edekoning@gmail.com
Website - http://sourceforge.net/projects/conanforqt
License - GPL (source code); CCL (icons)

Other sites hosting Conan include:

Other projects using Conan include:



Usage

    #include <Conan.h>          // checks for proper qt version and includes
                                // the ConanWidget and AboutDialog

    //Q_INIT_RESOURCE (Conan);  // necessary on some platforms when Conan
                                // is build as a static library
    conan::ConanWidget widget;
    widget.AddRootObject (myMainWindow);    // optional
    widget.AddRootObject (someOtherObject); // optional
    widget.show ();


Toolbar

Toolbar.jpg

The Conan toolbar


From left to right:

Object hierarchy

ObjectHierarchy.jpg

The Conan object hierarchy tree view


The Object Hierarchy tree view displayes the complete object hierarchy of one or more root objects. For each object, it displays the class name, object name, and object address. Note that this view is static in that it presents a snapshot in time of these hierarchies. The Refresh button from the toolbar can be used to synchronize the view with the current situation.

Root objects can be added manually through ConanWidget::AddRootObject or automatically by using the Discover objects toolbar button. The Object Hierarchy tree view will make sure that each root object belongs to an unique object hierarchy. This is achieved by looking if the 'to be added' root object has a mutual parent with an existing root object. If so, the existing root object is replaced by this mutual parent. F.e: Object A has a child object B and a child object C. If we first add B and then add C, B will be replaced by A (the mutual parent of B and C).

Root object can be removed through use of the context menu:

Note that removing a child (non-root) object is not allowed, as that same child object would reappear after pressing Refresh from the toolbar.



Class inheritance

Inheritance.jpg

The Conan class inheritance list


The Class Inheritance list shows how the current selected object in the Object Hierarchy tree view was derived from QObject. It does not present a complete class inheritance hierarchy, but merely an inheritance list from QObject to the actual class of the selected object.



Class information

ClassInformation.jpg

The Conan class information table


The Class Information table contains the extra class information of the current selected object. This meta data consists of key-value pairs that have been associated to the class using the Q_CLASSINFO macro.



Signals and Slots

SignalsSlots.jpg

The Conan signal and slot views


All signals of the current selected object are listed in the Signals view, and all slots of the current selected object are listed in the Slots view. Both views are static and can be updated using the Refresh button from the toolbar. For each signal/slot the following information is provided:

All methods that are connected to a signal or slot, are displayed as children of that particular signal or slot. For each connection the following information is provided:

Note that only connections between methods marked in code as signal or slot and processed by MOC are displayed. The conan::SignalSpy and QSignalSpy are examples of classes that have not been processed by MOC. They create connections directly by using the internal QMetaObject::connect. These types of connections are ignored.

The Signals and Slots views can be filtered using the following options:

A context menu with the following options is provided for both the Signals and the Slots view:



Signal spies

SignalSpies.jpg

The Conan signal spy table


The Signal spies table lists all existing signal spies. A signal spy monitors all emissions of a single signal. Each time it detects a signal emission, infomration about that signal emission is logged. For each signal spy the following information is provided:

Existing signal spies can be removed through use of the context menu:



Log options

LogOptions.jpg

The Conan signal spy log options


The log options define what information is logged by each signal spy and how each log is formatted. Currently all logging is performed through use of the qDebug function call. Two example logs are provided in the conan::ConanWidget that reflect the current options.

When the Arguments option is enabled, each argument used during a signal emission is converted to a string. If this is not possible, the type name of the argument's type is used instead. In case no type name is associated void is used. Type names can be registered using qRegisterMetaType.

Output.jpg

Conan signal spy output