Browse Source

Optimize map provider iteration to prevent app crashes

Changed from QHashIterator to using a constant iterator for iterating through the map providers in _providersTable. This change prevents application crashes during a map download session caused by the potential modification of an implicitly shared hash.
QGC4.4
Sergii Lisovenko 2 years ago committed by Patrick José Pereira
parent
commit
b0859bd13b
  1. 10
      src/QtLocationPlugin/QGCMapUrlEngine.cpp

10
src/QtLocationPlugin/QGCMapUrlEngine.cpp

@ -156,13 +156,9 @@ quint32 UrlFactory::averageSizeForType(const QString& type) {
} }
QString UrlFactory::getTypeFromId(int id) { QString UrlFactory::getTypeFromId(int id) {
for (auto it = _providersTable.constBegin(); it != _providersTable.constEnd(); ++it) {
QHashIterator<QString, MapProvider*> i(_providersTable); if ((int)(qHash(it.key()) >> 1) == id) {
return it.key();
while (i.hasNext()) {
i.next();
if ((int)(qHash(i.key())>>1) == id) {
return i.key();
} }
} }
qCDebug(QGCMapUrlEngineLog) << "getTypeFromId : id not found" << id; qCDebug(QGCMapUrlEngineLog) << "getTypeFromId : id not found" << id;

Loading…
Cancel
Save