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

Loading…
Cancel
Save