Logging queued connections

230 views Asked by At

I am using a complex state engine system build with Qt 5.4 (using custom state engine classes).

Part of that code is logging of events, transitions, etc. It is very important for me to log all events the engine/state objects are receiving so I can completely track what is happening in the state engines.

For most event types logging is easy. However I failed to log queued connections (i.e. meta call events). QMetaCallEvent is private so there is not much I can do. However it is hard to believe that such an integral part of Qt can not be inspected properly.

Is there some way I missed that allows to log queued connections (including signal name, slot name, sender name, receiver name and arguments if possible)?

2

There are 2 answers

0
Silicomancer On BEST ANSWER

There is no official API that allows to do what I intend.

Inspecting QMetaCall events (using private framework headers) is a bad idea. First they are private (and may break your code any time) second the QMetaCall event sender() pointer may be invalid if sender was deleted immediately and I could not find a clean way to inspect events in such cases.

The way I am using now is totally different. Instead of inspecting the arriving event objects I am using a modified variant of QSignalSpy that allows to do more than the original class and helps logging the signal emissions using secondary connections.

In my situation this seems feasible even if it is pretty complicated and not a universal solution. At least no private headers are involved.

1
cuteuser On

Install an event filter and intercept events with ev->type() == QEvent::MetaCall. All members visible in the debugger.

Need access to private headers? Use QT += core-private in your .pro file.

(tone mode="original poster")It's hard to believe that nobody reads documentation(/tone)