[Interest] Logging meta call events
Thiago Macieira
thiago.macieira at intel.com
Wed Feb 18 08:23:44 CET 2015
On Wednesday 18 February 2015 07:59:09 alexander golks wrote:
> if you really want to log, why not just include the private header and do
> the logging? we do it in our derived q(core)application::notify, when
> catching exceptions during notify:
>
> #include <../../src/qtbase/src/corelib/kernel/qobject_p.h>
>
> //...
> QMetaCallEvent* metaCallEvent=dynamic_cast<QMetaCallEvent*>(event);
> if(metaCallEvent)
> {
> eventInfo+="\nmetacall event";
> eventInfo+="\nevent id: "+QString::number(metaCallEvent->id());
> eventInfo+="\nevent sender: "+getObjectInfo(metaCallEvent->sender());
> eventInfo+="\nevent: "+QString::number(metaCallEvent->signalId());
> }
Meta call events only happen for queued slot deliveries. For direct
deliveries, there's no event, so notify() will not be called. For those, you
need to use the hooks that QSignalSpy uses.
One more thing: catching exceptions during notify() is too late. The exception
may have caused a lot of damage inside Qt before it reached notify(). If you
need to recover, you need to catch it earlier. If the exception reaches
notify(), you should interrupt the event loop and exit the application -- for
example, by rethrowing.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list