Skip to content

Commit d50ec80

Browse files
committed
Fixed JourneyProgressContainer
Fixed a bug(issue 11) where cover would show up as TERMINATED even though bus is still on route.
1 parent f70bcb2 commit d50ec80

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/logic/arrivals/journeyprogresscontainer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ THE SOFTWARE.
2828
#include "arrivalsproxymodel.h"
2929
#include "journeyprogressmodel.h"
3030

31-
//custom search algorithms because Qt algorithms are not sufficent and labmbdas or bind is not available in C++03 to use std algorithms
31+
//custom search algorithms because Qt algorithms are not sufficent and lambdas or bind is not available in C++03 to use std algorithms
3232
namespace {
3333
typedef QList<QPair<QString,double> > StopList;
3434
StopList::const_iterator find(StopList::const_iterator begin,StopList::const_iterator end, const QString& val) {
@@ -50,11 +50,14 @@ StopList::iterator find(StopList::iterator begin,StopList::iterator end, const Q
5050
//any other case it just returns end() iterator
5151
StopList::const_iterator findNextStop(StopList::const_iterator begin,StopList::const_iterator end, double val, double time) {
5252
for (StopList::const_iterator iter = begin; iter != end; ++iter) {
53-
if (iter->second - time > 0 && iter->second < val) return iter;
53+
if ((iter->second - time > 0)) {
54+
//if the original time is in the past and this isn't, then this is still better match,
55+
//otherwise only return if it is smaller then given value
56+
if (val - time < 0 || iter->second < val) { return iter; }
57+
}
5458
}
5559
return end;
5660
}
57-
5861
}//end of unnamed namespace
5962

6063
JourneyProgressContainer::JourneyProgressContainer(QObject* parent) : QObject(parent),
@@ -110,7 +113,6 @@ QString JourneyProgressContainer::getNextStop() const {
110113
}
111114
else return smallestSoFar->first;
112115
}
113-
114116
else {
115117
return QString("NOT AVAILABLE");
116118
}

0 commit comments

Comments
 (0)