Fix potential crash in getColor functions
If the index is out of range, just return black. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2c6830c399
commit
733108b473
@ -45,7 +45,9 @@ QString dpGasToStr(const divedatapoint& p)
|
||||
|
||||
QColor getColor(const color_indice_t i)
|
||||
{
|
||||
return profile_color[i].at(0);
|
||||
if ( profile_color.count() > i && i >= 0)
|
||||
return profile_color[i].at(0);
|
||||
return QColor(Qt::black);
|
||||
}
|
||||
|
||||
static DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||
|
||||
@ -58,5 +58,7 @@ void fill_profile_color()
|
||||
|
||||
QColor getColor(const color_indice_t i, bool isGrayscale = false)
|
||||
{
|
||||
return profile_color[i].at((isGrayscale) ? 1 : 0);
|
||||
if (profile_color.count() > i && i >= 0)
|
||||
return profile_color[i].at((isGrayscale) ? 1 : 0);
|
||||
return QColor(Qt::black);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user