I can't really see anywhere in this code that would cause a crash. What happens if you start the program and then immediately exit? (In other words, don't click the mouse in the view).