[Qt-interest] checking the return value of connect

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Sat Jul 9 09:24:11 CEST 2011


On Fri, Jul 8, 2011 at 9:15 PM, Scott Aron Bloom
<Scott.Bloom at onshorecs.com> wrote:
> Be very careful using assert that way.
>
> Depending on the assert implementation, it is possible, and likely, the
> inside of assert is NEVER executed.
>
> For instance, look at the definition of Q_ASSERT
> #if !defined(Q_ASSERT)
> #  ifndef QT_NO_DEBUG
> #    define Q_ASSERT(cond) ((!(cond)) ?
> qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
> #  else
> #    define Q_ASSERT(cond) qt_noop()
> #  endif
> #endif
>
> If its in debug, the condition is 100% ignore and will not be executed

Very true...in case of a 'release' build, the call inside an Q_ASSERT
would not be compiled in. Best to do an assert in a separate stmt.

-mandeep



More information about the Qt-interest-old mailing list