Closed justinbb closed 5 days ago
Problem occurs with official QGIS build, both PR 3.38.1 and LTR 3.34.9. I was not able to test older versions because Mac binary archiving at https://download.qgis.org/downloads/macOS/ stopped in 2019. Problem was not so obvious when I was doing similar work in August 2023, most likely with the latest point release. Problem discovered when returning to an atlas configured in 2023 which now demonstrates the problem. I have not been able to figure out why it happens now and didn't before (my configuration has Main Properties / Scale bound to an atlas variable, so one wonders why the scalingMode was now being forced to auto in contradiction with this setting).
@justinbb , thanks for reporting. Please provide a minimal reproducible example with a sample project a layer.
atlas bug sample.zip This sample project has a print layout with the map already rotated. Simply checking "Controlled by atlas" will provoke the bug.
I can confirm the issue also on Windows 10 using either QGIS 3.34.9, QGIS 3.36.1 or QGIS 3.38.1. The issue doesn't occur using QGIS 3.32.1 or QGIS 3.28.15.
@justinbb , thanks for taking the time to provide a sample project; it did wonders in figuring out what's wrong and fixing the underlying issue. You can expect it fixed in QGIS' next point release.
What is the bug or the crash?
It is not possible to create an atlas with a rotated map in recent QGIS versions (in the past year or so), because atlasScalingMode = Auto ("Margin around feature") is fragile, but is set by default.
If the map is rotated, turning on Controlled by Atlas hangs Layout Manager. If the project file is saved, it will be corrupt (though not too difficult to fix by manual editing), as numerous dimensions are saved as "nan". When the project is next opened, Layout Manager cannot recover from these bad dimensions.
To avoid failure, the atlas must be set up with no map rotation and atlasScalingMode can then be set to something other than Auto. Then it is safe to rotate the map, and things function normally thereafter, as long as the scaling mode does not return to Auto.
Steps to reproduce the issue
Versions
Supported QGIS version
New profile
Additional context
This issue may be related to #57872.
atlasScalingMode = Auto is a DWIM feature that sets off calculations based on assumptions that are neither tested nor even asserted in qgslayoutitemmap.cpp – rather perilous for something turned on by default. Once an arithmetic error occurs (nan), undetected, it spreads through the layout, like a spreadsheet with formulas referring to a cell that is missing or contains a bad value. Even saving the project is done naively, so the errors become persistent in the project. At this point all a regular user can do is delete the entire print layout and start over (taking great care to set up the atlas with an unrotated map and to set the scaling mode to fixed scale, only then rotating the map). Someone with the ability to extract the qgs file and edit it by hand can find all the "nan" values and replace them with valid numbers, and also change any occurrences of
AtlasMap scalingMode="2"
toscalingMode="0"
, and then the damage is contained and repaired. But none of this corruption should be possible in the first place…