]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/KLN89/kln89_page_fpl.cxx
Merge branch 'maint2' into next
[flightgear.git] / src / Instrumentation / KLN89 / kln89_page_fpl.cxx
index 0ed7cdff51872c319082975b2f0f8c316045282d..b789343713650ad9666bbd70e37156ca0272fd41 100644 (file)
@@ -26,7 +26,9 @@
 #endif
 
 #include "kln89_page_fpl.hxx"
+
 #include <algorithm>
+#include <iostream>
 
 using namespace std;
 
@@ -938,21 +940,21 @@ void KLN89FplPage::Knob2Left1() {
                                _bEntWp = true;
                                _fp0SelWpId.clear();    // Waypoints don't become the DTO default whilst being entered.
                                
-                               bool multi;
-                               const GPSWaypoint* wp = _kln89->FindFirstById(_entWpStr.substr(0, _wLinePos+1), multi, false);
+        GPSWaypoint* wp = _kln89->FindFirstById(_entWpStr.substr(0, _wLinePos+1));
                                if(NULL == wp) {
                                        // no-op
                                } else {
-                                       if(_entWp == NULL) {
-                                               _entWp = new GPSWaypoint;
-                                               if(_fplPos + (_uLinePos - 4) >= _kln89->_flightPlans[_subPage]->waypoints.size()) {
+                                       if(_entWp) {
+            *_entWp = *wp; // copy
+            delete wp;
+          } else {
+            _entWp = wp;
+            if(_fplPos + (_uLinePos - 4) >= _kln89->_flightPlans[_subPage]->waypoints.size()) {
                                                        _kln89->_flightPlans[_subPage]->waypoints.push_back(_entWp);
                                                } else {
                                                        _kln89->_flightPlans[_subPage]->waypoints.insert(_kln89->_flightPlans[_subPage]->waypoints.begin()+(_fplPos + (_uLinePos - 4)), _entWp);
                                                }
-                                       }
-                                       // copy
-                                       *_entWp = *wp;
+          }
                                }
                        }
                }
@@ -1011,21 +1013,21 @@ void KLN89FplPage::Knob2Right1() {
                                _bEntWp = true;
                                _fp0SelWpId.clear();    // Waypoints don't become the DTO default whilst being entered.
                                
-                               bool multi;
-                               const GPSWaypoint* wp = _kln89->FindFirstById(_entWpStr.substr(0, _wLinePos+1), multi, false);
+        GPSWaypoint* wp = _kln89->FindFirstById(_entWpStr.substr(0, _wLinePos+1));
                                if(NULL == wp) {
                                        // no-op
                                } else {
-                                       if(_entWp == NULL) {
-                                               _entWp = new GPSWaypoint;
-                                               if(_fplPos + (_uLinePos - 4) >= _kln89->_flightPlans[_subPage]->waypoints.size()) {
+                                       if(_entWp) {
+            *_entWp = *wp; // copy
+            delete wp;
+          } else {
+            _entWp = wp;
+            if(_fplPos + (_uLinePos - 4) >= _kln89->_flightPlans[_subPage]->waypoints.size()) {
                                                        _kln89->_flightPlans[_subPage]->waypoints.push_back(_entWp);
                                                } else {
                                                        _kln89->_flightPlans[_subPage]->waypoints.insert(_kln89->_flightPlans[_subPage]->waypoints.begin()+(_fplPos + (_uLinePos - 4)), _entWp);
                                                }
-                                       }
-                                       // copy
-                                       *_entWp = *wp;
+          }
                                }
                        }
                }