Results 1 to 4 of 4

Thread: Q_assert

  1. #1
    Join Date
    Feb 2013
    Posts
    50
    Thanks
    5

    Default Q_assert

    Hello,
    I tried using Q_ASSERT macro at several places and it seems not always it produces the output if the condition if false.

    Where to check for its output if the condition if false????

    The condition check worked, I got some No Source found for SignalKill or smth. But I could not
    find the output of Q_ASSERT (whereas I was able to do it in some other cases).

    ps. And how would you check for valid pointers using Q_ASSERT?

    pps. Btw. would such a check be oK? Q_ASSERT(pointer1 && pointer2 && pointer3)
    if I want to check multiple pointers.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Q_assert

    Q_ASSERT works only in debug mode. It doesn't provide output, it kills your app with a message that the assertion has failed.

    pps. Btw. would such a check be oK? Q_ASSERT(pointer1 && pointer2 && pointer3)
    if I want to check multiple pointers.
    Using three Q_CHECK_PTR calls would be cleaner. An assert with three pointers doesn't tell you which of them were null so from debugging point of view such assertion is rather useless.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2013
    Posts
    50
    Thanks
    5

    Default Re: Q_assert

    Quote Originally Posted by wysota View Post
    Q_ASSERT works only in debug mode. It doesn't provide output, it kills your app with a message that the assertion has failed.


    Using three Q_CHECK_PTR calls would be cleaner. An assert with three pointers doesn't tell you which of them were null so from debugging point of view such assertion is rather useless.
    Yes, it killed my app that's true. But the doc says: "Prints a warning message containing the source code file name and line number if test is false."
    http://qt-project.org/doc/qt-4.8/qtglobal.html#Q_ASSERT
    The thing is it killed my app but I could not find that warning message mentioned above... ??? (it did once though with other Q_ASSERT). Where to look for it? Thanks.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Q_assert

    Quote Originally Posted by ggdev001 View Post
    The thing is it killed my app but I could not find that warning message mentioned above... ???
    Maybe it's not an assertion that killed your app.

    Qt Code:
    1. #include <QtGlobal>
    2.  
    3. int main() {
    4. Q_ASSERT(false);
    5. return 0;
    6. }
    To copy to clipboard, switch view to plain text mode 

    ASSERT: "false" in file main.cpp, line 4
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QSortFilterProxyModel Q_Assert cm message.
    By pkj in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2012, 20:31
  2. Strange error message while using Q_ASSERT
    By homerun4711 in forum Newbie
    Replies: 2
    Last Post: 11th January 2011, 14:34
  3. How to break in debugger in Q_ASSERT ?
    By Radagast in forum Qt Programming
    Replies: 3
    Last Post: 24th May 2010, 13:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.