> Q_ASSERTs are not survivable. If you trip one, the application terminates.
I am not sure why I thought Q_CHECK_PTR would work even in release, when documentation clearly states they both do nothing if QT_NO_DEBUG was defined. By the way even using Q_ASSERT you still have to compare pointer it to null, this why pointer always should be initialized as I advised above. And I still do not see a reason to prefer Q_ASSERT over Q_CHECK_PTR when checking pointers for NULL, even though I would change the default message it prints to mention "NULL pointer" instead of "out of memory". It completely misleading especially since at least on Windows you might get not NULL pointer as a result of memory allocation even if process is out of memory and only attempt to use it will have result in exception thrown. Alex On Wed, Oct 3, 2012 at 4:01 PM, Thiago Macieira <thiago.macie...@intel.com> wrote: > On quarta-feira, 3 de outubro de 2012 15.50.30, Alex Malyushytskyy wrote: >> > That's not so good; Q_CHECK_PTR will print "Out of memory" upon seeing a >> >> Q_ASSERT just prints an assert information in debug > > Not really. > > Q_ASSERT, if it fails, calls qt_assert, which will abort the application with > a core dump (SIGABRT) or, on Windows, call the debugger routines indicating > failure. > > Q_ASSERTs are not survivable. If you trip one, the application terminates. > >> Q_CHECK_PTR terminates execution if you can't process, >> and this is the case, cause this pointer had to be initialized before >> the function is called. > > Q_CHECK_PTR only checks for null. It can't tell an invalid pointer from a > valid one. > >> Code can't recover from it. This should not happen, Stop is the best you can >> do. > > -- > Thiago Macieira - thiago.macieira (AT) intel.com > Software Architect - Intel Open Source Technology Center > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest