Skip to content

Commit 2651a2d

Browse files
author
mhugent
committed
Safer generation of ids for composer map
git-svn-id: http://svn.osgeo.org/qgis/trunk@15040 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e0bf276 commit 2651a2d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/core/composer/qgscomposermap.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,20 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int w
4747
mCrossLength( 3 ), mMapCanvas( 0 ), mDrawCanvasItems( true )
4848
{
4949
mComposition = composition;
50-
mId = mComposition->composerMapItems().size();
50+
51+
//mId = mComposition->composerMapItems().size();
52+
int maxId = -1;
53+
QList<const QgsComposerMap*> mapList = mComposition->composerMapItems();
54+
QList<const QgsComposerMap*>::const_iterator mapIt = mapList.constBegin();
55+
for ( ; mapIt != mapList.constEnd(); ++mapIt )
56+
{
57+
if (( *mapIt )->id() > maxId )
58+
{
59+
maxId = ( *mapIt )->id();
60+
}
61+
}
62+
mId = maxId + 1;
63+
5164
mMapRenderer = mComposition->mapRenderer();
5265
mPreviewMode = QgsComposerMap::Rectangle;
5366
mCurrentRectangle = rect();

0 commit comments

Comments
 (0)