Fix route-path crashes on empty
This could be triggered by doing ‘view route’ in the launcher flight- planning code, wit no route defined.
This commit is contained in:
parent
f8aea84541
commit
77d7476ba6
1 changed files with 10 additions and 3 deletions
|
@ -935,6 +935,10 @@ void RoutePath::commonInit()
|
||||||
|
|
||||||
SGGeodVec RoutePath::pathForIndex(int index) const
|
SGGeodVec RoutePath::pathForIndex(int index) const
|
||||||
{
|
{
|
||||||
|
if ((index < 0) || (index >= static_cast<int>(d->waypoints.size()))) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
const WayptData& w(d->waypoints[index]);
|
const WayptData& w(d->waypoints[index]);
|
||||||
const std::string& ty(w.wpt->type());
|
const std::string& ty(w.wpt->type());
|
||||||
SGGeodVec r;
|
SGGeodVec r;
|
||||||
|
@ -1029,6 +1033,10 @@ void RoutePath::interpolateGreatCircle(const SGGeod& aFrom, const SGGeod& aTo, S
|
||||||
|
|
||||||
SGGeod RoutePath::positionForIndex(int index) const
|
SGGeod RoutePath::positionForIndex(int index) const
|
||||||
{
|
{
|
||||||
|
if ((index < 0) || (index >= static_cast<int>(d->waypoints.size()))) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
return d->waypoints[index].pos;
|
return d->waypoints[index].pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1096,9 +1104,8 @@ SGGeodVec RoutePath::pathForHold(Hold* hold) const
|
||||||
|
|
||||||
double RoutePath::computeDistanceForIndex(int index) const
|
double RoutePath::computeDistanceForIndex(int index) const
|
||||||
{
|
{
|
||||||
if ((index < 0) || (index >= (int) d->waypoints.size())) {
|
if ((index < 0) || (index >= static_cast<int>(d->waypoints.size()))) {
|
||||||
throw sg_range_exception("waypt index out of range",
|
return 0.0;
|
||||||
"RoutePath::computeDistanceForIndex");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = d->waypoints.begin() + index;
|
auto it = d->waypoints.begin() + index;
|
||||||
|
|
Loading…
Add table
Reference in a new issue