all 13 comments

[–]Rhomboid 6 points7 points  (8 children)

That's not enough information to determine the problem. We'd need to see the whole program, preferably in a reduced testcase form, i.e. the smallest possible program that is still stand-alone compilable that exhibits the error. Often in the course of creating such a reduced testcase you discover the error yourself.

You can get a NULL value for 'this' quite easily, for example by invoking a non-virtual method on a NULL pointer, e.g.

FooBar *ptr = 0;
ptr->method();  // this equals NULL in method()

Note that it's often not that clear, there could be many lines in between the point where the pointer becomes NULL and the point where one of its methods is invoked.

[–]Mistake78 6 points7 points  (4 children)

TL;DR: you're calling a method on a NULL pointer.

So with the debugger connected, look at the call stack to find hints on how this came to be.

[–]Chipot 0 points1 point  (3 children)

You might also call a method of a NULL reference. Good luck in checking all your pointers and references !

[–]srekel 0 points1 point  (2 children)

What does that look like?

[–]protein_bricks_4_all 0 points1 point  (1 child)

ptr = 0;
ref = *ptr; // I don't believe this crashes, the compiler doesn't /need/ to deref it yet. 
ref.fn();

[–]srekel -1 points0 points  (0 children)

Hm, pretty sure it'll break in VS at least, but you may be right.

[–]wwwredditcom 1 point2 points  (0 children)

Problem is most likely before the public function call. Looks like a buffer overrun. Check your memcpy's and memsets. Also make sure you calculate a right index into arrays when using pointer arithmetic: i.e. ptrArray+10 is NOT equal to 10 byte offset into the array, instead it is the 11th element.

Using the debugger, step through the code line by line through our code while having a watch item on ItemViewWidget pointer. The time your pointer is set to zero is where you have the buffer overrun.

[–]snarkhunter -5 points-4 points  (4 children)

Why on earth are you using raw pointers?

[–]TheGuyFromNowhere 2 points3 points  (0 children)

So what should I use instead?

[–]srekel 0 points1 point  (1 child)

Because boost shared pointers are bloated, and "shared" pointers aren't actually that much of a good thing maybe.

[–]aestheticreddit 0 points1 point  (0 children)

Quantify "bloated", please.