motioncells: protect against not found id

If searchIdx() doesn't find the id it returns -1, which breaks
motioncelssvector.at (idx). Check for it and return if not found.

Changing a few other lines for style consistency.
This commit is contained in:
Luis de Bethencourt 2015-03-05 15:54:55 +00:00
parent 632854eba3
commit 290508932e

View file

@ -89,12 +89,15 @@ perform_detection_motion_cells (IplImage * p_image, double p_sensitivity,
{
int idx = 0;
idx = searchIdx (p_id);
if (idx > -1)
return motioncellsvector.at (idx).mc->performDetectionMotionCells (p_image,
p_sensitivity, p_framerate, p_gridx, p_gridy, p_timestamp_millisec,
p_isVisible, p_useAlpha, motionmaskcoord_count, motionmaskcoords,
motionmaskcells_count, motionmaskcellsidx, motioncellscolor,
motioncells_count, motioncellsidx, starttime, p_datafile,
p_changed_datafile, p_thickness);
else
return -1;
}
@ -103,6 +106,7 @@ setPrevFrame (IplImage * p_prevFrame, int p_id)
{
int idx = 0;
idx = searchIdx (p_id);
if (idx > -1)
motioncellsvector.at (idx).mc->setPrevFrame (p_prevFrame);
}
@ -113,12 +117,10 @@ getMotionCellsIdx (int p_id)
idx = searchIdx (p_id);
if (idx > -1)
return motioncellsvector.at (idx).mc->getMotionCellsIdx ();
else {
else
return p_str;
}
}
int
getMotionCellsIdxCnt (int p_id)
{
@ -161,10 +163,9 @@ getInitDataFileFailed (int p_id)
idx = searchIdx (p_id);
if (idx > -1)
return motioncellsvector.at (idx).mc->getDatafileInitFailed ();
else {
else
return p_str;
}
}
char *
getSaveDataFileFailed (int p_id)
@ -173,10 +174,9 @@ getSaveDataFileFailed (int p_id)
idx = searchIdx (p_id);
if (idx > -1)
return motioncellsvector.at (idx).mc->getDatafileSaveFailed ();
else {
else
return p_str;
}
}
int
getInitErrorCode (int p_id)