View Single Post
  #2   Spotlight this post!  
Unread 28-01-2012, 00:34
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Uncaught C++ Exception

Hi,
I have some concern about the idea of assigning 'particles = *temp' and deleting temp rather than simply USING temp-> in the routine and then deleting temp at the end, but that isn't looking like the culprit. I see
Code:
			targetParticle = particles.at(0);
as a big issue -- when there are no particles at all in the image, particles.size() or temp->size() if not deleted are zero. This means you CANNOT assign targetParticle = particles.at(0); as there is NO ZEROTH ELEMENT at that time. If you, instead, carefully deal with placing that part inside an
Code:
if (particles.size()) {
  targetParticle = particles.at(0);
  flagNoParticles = false;
}
else
  flagNoParticles = true;
then that part won't crash. HOWEVER, it seems that elsewhere in the code you are counting on targetParticle to be valid. You might have to be a little creative (using a flag or re-thinking your logic) in treating this special case such that where you are counting on targetParticle, you are checking to see if you are in the situation where there are none instead and just returning in those cases. It's a little hard to describe in words...if this isn't clear, maybe we could talk it out on the phone.

bob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote