> -----Original Message-----
> From: Giuseppe D'Angelo [mailto:[email protected]]
> Sent: Wednesday, January 08, 2014 9:54 AM
> To: Koehne Kai
> Cc: [email protected]
> Subject: Re: [Development] Let's get rid of qDebug/qWarning/qCritical!
>
> On 8 January 2014 09:35, Koehne Kai <[email protected]> wrote:
> > - Current #ifdef's, environment variables etc should be replaced with
> > an unconditional qCDebug/qCWarning/qCCritical
>
> That's not doable in 100% of the cases, f.i. if one has to compile extra code
> to
> get the debug information that needs to be printed.
You can then use it like that:
If (qtCoreIo().isDebugEnabled()) {
QString x = expensive();
qCDebug(qtCoreIo) << "Expensive: " << x;
}
Anyhow, note that qCDebug(qtCoreIo) expands to
for (bool enabled = qtCoreIo().isDebugEnabled(); Q_UNLIKELY(enabled); enabled =
false)
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO,
qtCoreIo().categoryName()).debug() <<
so this should be needed only if your 'expensive' operations aren't behind the
<< anyway.
> Also, what's the overhead of a qCDebug for a disabled category? Qt should
> never emit debug warnings in its default configuration, so we're talking about
> many hits to that.
The overhead for a non-enabled qCDebug is basically a function call + one
boolean check (isDebugEnabled() will be inlined).
Regards
Kai
>
> --
> Giuseppe D'Angelo
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development