SG_LOG(SG_AUTOPILOT, SG_WARN, "removeWayptAtIndex with invalid index:" << aIndex);
return NULL;
}
-
- if (_currentIndex > index) {
- --_currentIndex; // shift current index down if necessary
- }
-
WayptVec::iterator it = _route.begin();
it += index;
_route.erase(it);
update_mirror();
+
+ if (_currentIndex == index) {
+ currentWaypointChanged(); // current waypoint was removed
+ }
+ else
+ if (_currentIndex > index) {
+ --_currentIndex; // shift current index down if necessary
+ }
+
_edited->fireValueChanged();
checkFinished();
WayptVec::iterator it = _route.begin();
it += index;
- if (_currentIndex > index) {
+ if (_currentIndex >= index) {
++_currentIndex;
}
--destIndex;
}
+ int currentWpIndex = currentWaypoint();
WayptRef w(_rm->removeWayptAtIndex(srcIndex));
SG_LOG(SG_GENERAL, SG_INFO, "wpt:" << w->ident());
_rm->insertWayptAtIndex(w, destIndex);
+
+ if (srcIndex == currentWpIndex) {
+ // current waypoint was moved
+ _rm->jumpToIndex(destIndex);
+ }
}
virtual void setUpdateCallback(SGCallback* cb)