mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Crash fix: prevent crash in MapLocationModel::reload
Commit 0c38754916
introduced a
bug in MapLocationModel::reload() by setting an entry in the
name-to-location map before the location was initialized.
Move the setting of the map entry back where it was before:
after the assignment of the location variable.
Moreover, define the location variable directly on allocation
of the location to avoid thus bugs in the future.
Why did we not get a "might be used unitialized" warning
anyway?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
a0cd89f850
commit
b0f1b25806
2 changed files with 4 additions and 4 deletions
|
@ -140,7 +140,6 @@ void MapLocationModel::reload(QObject *map)
|
|||
m_selectedDs.clear();
|
||||
|
||||
QMap<QString, MapLocation *> locationNameMap;
|
||||
MapLocation *location;
|
||||
|
||||
#ifdef SUBSURFACE_MOBILE
|
||||
bool diveSiteMode = false;
|
||||
|
@ -184,10 +183,11 @@ void MapLocationModel::reload(QObject *map)
|
|||
if (dsCoord.distanceTo(coord) < MIN_DISTANCE_BETWEEN_DIVE_SITES_M)
|
||||
continue;
|
||||
}
|
||||
locationNameMap[name] = location;
|
||||
}
|
||||
location = new MapLocation(ds, dsCoord, name);
|
||||
MapLocation *location = new MapLocation(ds, dsCoord, name);
|
||||
m_mapLocations.append(location);
|
||||
if (!diveSiteMode)
|
||||
locationNameMap[name] = location;
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue