[Qt-interest] checking the return value of connect
Scott Aron Bloom
Scott.Bloom at onshorecs.com
Fri Jul 8 17:45:29 CEST 2011
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
Scott
-----Original Message-----
From: qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com
[mailto:qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com] On
Behalf Of Atlant Schmidt
Sent: Friday, July 08, 2011 8:33 AM
To: 'Mandeep Sandhu'; Thiago Macieira
Cc: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] checking the return value of connect
Mandeep:
If connect() fails, you might want to ASSERT(); we do.
So ASSERT( connect( ... ) );
Atlant
-----Original Message-----
From: qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com
[mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On
Behalf Of Mandeep Sandhu
Sent: Friday, July 08, 2011 09:46
To: Thiago Macieira
Cc: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] checking the return value of connect
> Considering QObject::connect prints a warning when it can't connect,
> why were you spending time searching for the problem before fixing the
warning?
Because of the verbosity of my logs! :) It got lost in the storm of logs
generated (it was running on an embedded box and there was no color
support for different log levels).
-mandeep
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
This e-mail and the information, including any attachments, it contains
are intended to be a confidential communication only to the person or
entity to whom it is addressed and may contain information that is
privileged. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, distribution or copying
of this communication is strictly prohibited. If you have received this
communication in error, please immediately notify the sender and destroy
the original message.
Thank you.
Please consider the environment before printing this email.
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list