Results 1 to 4 of 4

Thread: Function call from a NULL this object ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2010
    Posts
    63
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Function call from a NULL this object ?

    Hi all,

    so my program produced a crash and I ran the debugger. The crash occurs in the following code segment:

    Qt Code:
    1. void RFormulaData::setSpecies(int nr, const RFormSpecies& sp0)
    2. {
    3. if ((nr < 0) || (nr > 5)) return;
    4. sp[nr] = sp0; // line with the crash
    5. }
    To copy to clipboard, switch view to plain text mode 

    The debugger shows the watches seen in the attached screenshot. And this is what confuses me. Apparently the this pointer whose function has already been called is NULL. I've never seen this before. I thought I would get a crash if I tried to call a function from any object pointer that is NULL and never make it into that function.

    The data itself is pretty harmless, I think. 'sp' is just a statically allocated array of type RFormSpecies and size 6.

    Can someone explain how I can be inside the function of a null object, or direct me to an explanation, and give me hint how to solve this problem ?
    Thank you !
    Attached Images Attached Images
    Hint: Think carefully before picking a user name.

Similar Threads

  1. cannot call member function without object
    By been_1990 in forum Qt Programming
    Replies: 11
    Last Post: 23rd October 2010, 17:12
  2. Check if a object is null and destroy objects
    By ruben.rodrigues in forum Newbie
    Replies: 3
    Last Post: 2nd July 2010, 10:25
  3. Replies: 2
    Last Post: 7th July 2009, 17:44
  4. Cannot call function without object
    By Salazaar in forum Newbie
    Replies: 5
    Last Post: 11th June 2007, 14:55
  5. Replies: 3
    Last Post: 16th May 2007, 11:07

Tags for this Thread

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.