[QGIS Commit] r14926 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Dec 16 09:53:58 EST 2010


Author: jef
Date: 2010-12-16 06:53:58 -0800 (Thu, 16 Dec 2010)
New Revision: 14926

Modified:
   trunk/qgis/src/core/qgsmaplayerregistry.cpp
Log:
fix crash on quit

Modified: trunk/qgis/src/core/qgsmaplayerregistry.cpp
===================================================================
--- trunk/qgis/src/core/qgsmaplayerregistry.cpp	2010-12-16 08:32:31 UTC (rev 14925)
+++ trunk/qgis/src/core/qgsmaplayerregistry.cpp	2010-12-16 14:53:58 UTC (rev 14926)
@@ -102,19 +102,19 @@
 void QgsMapLayerRegistry::removeAllMapLayers()
 {
   // moved before physically removing the layers
-  emit removedAll();            // now let all canvas Observers know to clear
-  // themselves, and then consequently any of
-  // their map legends
+  emit removedAll();
 
-  QMap<QString, QgsMapLayer *>::iterator it;
-  for ( it = mMapLayers.begin(); it != mMapLayers.end() ; ++it )
+  // now let all canvas observers know to clear themselves,
+  // and then consequently any of their map legends
+  while ( mMapLayers.size() > 0 )
   {
-    emit layerWillBeRemoved( it.key() );
-    delete it.value(); // delete the map layer
-    mMapLayers.remove( it.key() );
+    QString id = mMapLayers.begin().key();
+    emit layerWillBeRemoved( id );
+    delete mMapLayers[ id ]; // delete the map layer
+    mMapLayers.remove( id );
   }
+
   mMapLayers.clear();
-
 } // QgsMapLayerRegistry::removeAllMapLayers()
 
 //Added in QGIS 1.4



More information about the QGIS-commit mailing list