Prevent crash when attempting to move marker on empty trace

This commit is contained in:
Jan Käberich 2021-11-13 19:48:03 +01:00
parent e3ce765e64
commit 1bf0e45f7c
2 changed files with 11 additions and 1 deletions

View File

@ -1560,6 +1560,9 @@ bool Marker::isMovable()
// helper traces are never movable by the user // helper traces are never movable by the user
return false; return false;
} }
if(trace()->size() == 0) {
return false;
}
switch(type) { switch(type) {
case Type::Manual: case Type::Manual:
case Type::Delta: case Type::Delta:

View File

@ -84,7 +84,14 @@ TraceMath::TypeInfo TraceMath::getInfo(TraceMath::Type type)
TraceMath::Data TraceMath::getSample(unsigned int index) TraceMath::Data TraceMath::getSample(unsigned int index)
{ {
return data.at(index); if(index < data.size()) {
return data[index];
} else {
TraceMath::Data d;
d.x = 0;
d.y = 0;
return d;
}
} }
double TraceMath::getStepResponse(unsigned int index) double TraceMath::getStepResponse(unsigned int index)