mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make QMap<> access in deleteGpsFix() more idiomatic
To access a QMap<> entry, the value() function is used with a sentinel as default value. If the sentinel is returned, the code assumes that the searched for entry doesn't exist. Make this code more idiomatic by using an iterator and testing for end(). This fixes a compiler warning, because only one of the elements of the sentinel was initialized, but the remaining elements were copied. Harmless, because the code would exit early if it found the sentinel. Still not nice. While redoing this function, the entry-not-found message was improved (adding of function name, space between massage and timestamp) and elevated from debug to warning level. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
22dc7b84f0
commit
28ae35e7df
1 changed files with 4 additions and 5 deletions
|
@ -436,13 +436,12 @@ void GpsLocation::deleteFixFromStorage(gpsTracker >)
|
|||
|
||||
void GpsLocation::deleteGpsFix(qint64 when)
|
||||
{
|
||||
struct gpsTracker defaultTracker;
|
||||
defaultTracker.when = 0;
|
||||
struct gpsTracker deletedTracker = m_trackers.value(when, defaultTracker);
|
||||
if (deletedTracker.when != when) {
|
||||
qDebug() << "can't find tracker for timestamp" << when;
|
||||
auto it = m_trackers.find(when);
|
||||
if (it == m_trackers.end()) {
|
||||
qWarning() << "GpsLocation::deleteGpsFix(): can't find tracker for timestamp " << when;
|
||||
return;
|
||||
}
|
||||
struct gpsTracker deletedTracker = *it;
|
||||
deleteFixFromStorage(deletedTracker);
|
||||
m_deletedTrackers.append(deletedTracker);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue