Bug report #14812

Saving / re-openning a project reverse the annotations z-order

Added by Arnaud Morvan over 8 years ago. Updated over 8 years ago.

Status:Closed
Priority:Low
Assignee:-
Category:Project Loading/Saving
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:22768

Description

To reproduce :

- Create a project
- Add an annotation
- Add a second annotation that overlap the first one.
- Save the project.
- Re-open the project.

=> The annotations display in reversed z-order.

Note : I don't see any possibility to manage the annotations z-order.

14812.patch.txt Magnifier - git diff --patch > /tmp/14812.patch.txt (799 Bytes) Simon Chenery, 2016-05-16 12:33 PM

Associated revisions

Revision 82d465cd
Added by Simon Chenery over 8 years ago

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.

Revision e63e9eb8
Added by Nyall Dawson over 8 years ago

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 82d465cd9434d4445fe4fa44af8a5fd085cbc566)

History

#1 Updated by Simon Chenery over 8 years ago

If I create three Text Annotations 'Annotation1', 'Annotation2' and 'Annotation3' and save the project, then the Text Annotations are saved in order 'Annotation3', 'Annotation2', 'Annotation1' in the project.qgs file.

This is because QgsMapCanvas::items() (from parent class QGraphicsView::items()) returns the items in "stacking order" with the uppermost item 'Annotation3' first, and QgisApp::writeAnnotationItemsToProject saves the Text Annotations in this order too.

When I load the project again, 'Annotation1' is now on top, although it was on the bottom before.

Solution is to go through the QgsAnnotationItem list in reverse order when saving the project.qgs file -- this logic is already used in QgsMapCanvas::saveAsImage for creating an image file.

A master patch is attached (git diff --patch > /tmp/14812.patch.txt).

#2 Updated by Simon Chenery over 8 years ago

Also created a pull request https://github.com/qgis/QGIS/pull/3074

#3 Updated by Simon Chenery over 8 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF