Results 1 to 6 of 6

Thread: QTestLib doesn't recognize NULL pointers?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 7 Times in 7 Posts

    Default Re: QTestLib doesn't recognize NULL pointers?

    Ok, this sounds logical.
    I'm accessing nothing class-specific in that method. I'm just returning a new QString Object...

    Qt Code:
    1. QString HelloWorld::hello()
    2. {
    3. return "Hello World!";
    4. }
    To copy to clipboard, switch view to plain text mode 

    So... i've just tested it with this:

    Qt Code:
    1. QString HelloWorld::hello()
    2. {
    3. _string = "Hello World!";
    4. return _string;
    5. }
    To copy to clipboard, switch view to plain text mode 

    ...while _string is a member of HelloWorld class. And now it crashes, like it should!

    Wondering if the compiler is optimizing the return "Hello World"; from the first hello() method out, and that is the reason no crash occures.
    Or what other reason there is, why there's no error at runtime...?

    Thank you!

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

    Default Re: QTestLib doesn't recognize NULL pointers?

    No crash occurs because the compiler never tries to dereference "this" when inside the hello() method. If you make that method virtual, it will start crashing.
    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. The following user says thank you to wysota for this useful post:

    entonjackson (12th October 2011)

  4. #3
    Join Date
    Sep 2011
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 7 Times in 7 Posts

    Default Re: QTestLib doesn't recognize NULL pointers?

    Ok!
    Thanks a lot!

Similar Threads

  1. qtestlib
    By Jordan in forum Qt Programming
    Replies: 7
    Last Post: 28th September 2010, 11:47
  2. Replies: 1
    Last Post: 23rd July 2010, 13:10
  3. Pointers: NULL vs. 0
    By hackerNovitiate in forum Newbie
    Replies: 6
    Last Post: 2nd February 2010, 16:20
  4. How do I get Qt to recognize the oci driver.
    By yleesun in forum Qt Programming
    Replies: 11
    Last Post: 19th January 2009, 03:50
  5. Getting Qt to recognize plugins...
    By KShots in forum Qt Programming
    Replies: 4
    Last Post: 21st April 2007, 10:05

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
  •  
Qt is a trademark of The Qt Company.