Qt5 + DockedFormEditor: .lfm corruption
- Lazarus/FPC Version: Lazarus 2.2.0RC2 (rev t-fixes-2_2-245-gd03e2443) FPC 3.3.1 x86_64-linux-qt5
- Lazarus/FPC Version: Lazarus 2.3.0 (rev main-2_3-430-g2b295d76) FPC 3.3.1 x86_64-linux-qt5
- Operating System: Linux (Kubuntu 20.04)
- CPU / Bitness: x86_64
What happens
Forms that have not yet been shown in the form editor since Lazarus start can be corrupted on saving
This does not happen with every Form, it seems it needs to have some complexity, anchoring, etc., it took quite a while and lots of trial and error to put this demo form together (trying to mimic a similar form of a real project of mine) and today I finally got it to exhibit the bug after I added MinWidth and MinHeight to it, but I can't tell whether this is directly related, it might also just be a coincidence.
I can now reliably replicate the bug on fixes-2.2 and main using this demo project.
What did you expect
No corruption
Steps to reproduce
- Have Lazarus fixes_2_2 installed (or current main branch will also do)
- with Qt5
- with AnchorDockingDsgn
- with DockedFormEditor
- Preferrably have 96 DPI on your workstation (not yet sure if related, project is saved in 96)
- Close Lazarus
The bug will only occur once after fresh start of Lazarus, so in order to reproduce please follow the steps exactly as written and do not click anywhere else, especially do not click the form tab unless told explicitly.
The demo project contains a git repo, so you can just git reset --hard everytime the files got corrupted to reset it to the initial state
- Unzip the demo project demo-lfm-corruption.zip (or git reset --hard inside this folder if you want to try a second time)
- Start Lazarus (must be freshly started!)
- Open the project (do NOT click anywhere!)
- Run | Run
- observe the form in its intended uncorrupted state
- TChart ends 5px above Buttons row
- TChart ends 5px before right form edge
- Edit something in Unit1.pas, for example insert an empty line somewhere
- Hit Ctrl + S to save the modified unit
- Run | Run
- observe that the form is now corrupted
- TChart underlaps the Buttons on bottom
- TChart extends far beyond right form edge
- have look at the git diff to see what happened to the .lfm file when the form was saved.
The above can not be reproduced when DockedFormEditor is not installed or the form has been shown in DockedFormEditor before saving it. Once shown in DockedFormEditor there will be no more corruption for the rest of the day until Lazarus is closed again:
- Close Lazarus
- Reset the demo project (git reset --hard)
- Start Lazarus, open the project
- Click the "Form" tab to show DockedFormEditor (This one action makes the difference!)
- Click the "Code" tab to show the unit
- Insert an empty line somewhere
- Hit Ctrl + S to save the modified unit
- Run | Run
- observe that no corruption has happened
- git diff shows no change to the .lfm