Gui: Allow to unset modified state #13200
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
GuiDocuments have a "Modified" attribute that says if the doc has been modified or not (and prints an * in the titlebar). This attribute is read-only in the python interface (only getter is defined).
With NativeIFC, we are handling IFC files natively in FreeCAD, so all file loading/saving is done inside the module already, there is no more saving to .FCStd files. Last bit missing, not be annoyed by FreeCAD that the document has not been saved.
So this implements a resetModified() python method to unset the Modified flag.
I considered making the Modified attribute writable (implement a setter), but I'm not sure... People could play wrongly with that and they would loose the warning to save the file when closing FreeCAD. I thought maybe more interesting to implement a specific method, so people would be more aware of what they are doing and would be less prone to reset the modified state accidentally.
Not sure if that makes sense... What do you think @wwmayer ? @adrianinsaval ?
EDIT Following Werner's suggestion, this now sets the Modified attribute as read/write (previously read-only)