[QGIS Commit] r15040 - trunk/qgis/src/core/composer

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Jan 14 05:17:32 EST 2011


Author: mhugent
Date: 2011-01-14 02:17:32 -0800 (Fri, 14 Jan 2011)
New Revision: 15040

Modified:
   trunk/qgis/src/core/composer/qgscomposermap.cpp
Log:
Safer generation of ids for composer map

Modified: trunk/qgis/src/core/composer/qgscomposermap.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposermap.cpp	2011-01-14 08:11:38 UTC (rev 15039)
+++ trunk/qgis/src/core/composer/qgscomposermap.cpp	2011-01-14 10:17:32 UTC (rev 15040)
@@ -47,7 +47,20 @@
     mCrossLength( 3 ), mMapCanvas( 0 ), mDrawCanvasItems( true )
 {
   mComposition = composition;
-  mId = mComposition->composerMapItems().size();
+
+  //mId = mComposition->composerMapItems().size();
+  int maxId = -1;
+  QList<const QgsComposerMap*> mapList = mComposition->composerMapItems();
+  QList<const QgsComposerMap*>::const_iterator mapIt = mapList.constBegin();
+  for ( ; mapIt != mapList.constEnd(); ++mapIt )
+  {
+    if (( *mapIt )->id() > maxId )
+    {
+      maxId = ( *mapIt )->id();
+    }
+  }
+  mId = maxId + 1;
+
   mMapRenderer = mComposition->mapRenderer();
   mPreviewMode = QgsComposerMap::Rectangle;
   mCurrentRectangle = rect();



More information about the QGIS-commit mailing list