Skip to content

Commit e63e9eb

Browse files
committed
Save annotations to project.qgs in creation order (fix #14812)
Save annotations to project file in the order they were loaded or created, so that annotations have the same display order each time the project is opened. (cherry-picked from 82d465c)
1 parent a2756b9 commit e63e9eb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/app/qgisapp.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -1574,14 +1574,19 @@ void QgisApp::showStyleManagerV2()
15741574
void QgisApp::writeAnnotationItemsToProject( QDomDocument& doc )
15751575
{
15761576
QList<QgsAnnotationItem*> items = annotationItems();
1577-
QList<QgsAnnotationItem*>::const_iterator itemIt = items.constBegin();
1578-
for ( ; itemIt != items.constEnd(); ++itemIt )
1577+
QgsAnnotationItem* item;
1578+
QListIterator<QgsAnnotationItem*> i( items );
1579+
// save lowermost annotation (at end of list) first
1580+
i.toBack();
1581+
while ( i.hasPrevious() )
15791582
{
1580-
if ( ! *itemIt )
1583+
item = i.previous();
1584+
1585+
if ( ! item )
15811586
{
15821587
continue;
15831588
}
1584-
( *itemIt )->writeXML( doc );
1589+
item->writeXML( doc );
15851590
}
15861591
}
15871592

0 commit comments

Comments
 (0)