Skip to content

GUI: simplify save/load machinery

Mikhail Svechnikov requested to merge i418b into main

This MR is about reorganization of saving and loading datafield files. The aim was to simplify logic, make it traceable and eliminate artificial references to parent JobItem for updating its status (#365 (closed)).

The former mechanism looked overingineered, it was really hard to follow the logic. There were numerous services responsible for saving and loading datafield files and tracking changes to them: DatafieldIOService, DatafieldIOHistory, DatafieldDirHistory, DatafieldSaveInfo, SaveService, SaveThread. The data was saved and read in the following order: first the project file was read and only then all the data files, one by one.

Now, after the simplification, the above-mentioned classes have been removed from code and their functionality has been moved to ProjectManager, ProjectDocument, ApplicationModels, DataItem. The data file for each JobItem or RealItem is saved or loaded immediately after reading or writing the xml data. So the method DataItem::saveDatafield() is called from the corresponding DataItem::writeTo() method and DataItem::loadDatafield() is called from the JobItem::readFrom() or RealItem::readFrom(). Each data is saved in a separate thread in the background.

Tests that tested redundant functionality of removed classes have been removed. The rest was adapted and test files were renamed:

TestIOService --> TestApplicationModel

TestSaveService --> TestAutosaveController

Minor changes:

  1. The functions and variables to set/get full address of the project file have been renamed from projectFileName() to projectFullPath() to avoid confusing, because projectFileName can be misunderstood as Untitled.pro instead of /some/way/to/project/Untitled.pro

  2. The nofitication of the project has been restored for loading and removal user data in the Data view.

  3. Some issues with synchronized representation in jobs containing user data have been fixed.

  4. Missing or corrupted datafiles are allowed now. The handling of such cases has been restored.

This resolves #418 (closed), #364 (closed), #365 (closed)

Edited by Mikhail Svechnikov

Merge request reports