As I count it, you have 8 or 9 pointers being retrieved or used in one method call or another, and not one of them is ever checked to see if it is actually a valid pointer. Nor do you ever check to see if the model indexes you are throwing around are valid. Who knows where it could be failing? Your code certainly doesn't.