[FIXED] Ticket #4098 - Data loss on close

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

[FIXED] Ticket #4098 - Data loss on close

Post by kisolre »

Create an empty folder.
Create new FreeCAD file, draw something, write file in that folder.
Draw some more - file is modified.
Rename the folder.
Try to close the file - "Unsaved document" prompt pops up. Confirm save - Exception is thrown, file is closed, latest modifications are lost.

Code: Select all

22:47:54  <Exception> Failed to open file: FileRenameTest.FCStd.7c5fee36-959d-456d-bcdb-7d2ba8c254ad
OS: Windows 8.1 Version 6.3 (Build 9600)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24219 (Git)
Build type: Release
Branch: master
Hash: 8c26baebab320b8c1c3279bc8eb34a1eb6c7a363
Python version: 3.8.6+
Qt version: 5.15.1
Coin version: 4.0.1
OCC version: 7.5.0
Locale: Bulgarian/Bulgaria (bg_BG)

I will probably not have Internet to continue the thread.
Last edited by Kunda1 on Fri Sep 17, 2021 1:13 am, edited 2 times in total.
Reason: Added [Fixed] to thread title
chrisb
Veteran
Posts: 54288
Joined: Tue Mar 17, 2015 9:14 am

Re: Data loss on close

Post by chrisb »

We have seen something similar with write protected files.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: Data loss on close

Post by kisolre »

chrisb wrote: Fri Feb 26, 2021 11:05 pm We have seen something similar with write protected files.
And this is clearly not expected behavior. FreeCAD should prompt to save to a new file name or issue a warning and not close the file, or anything that will not cause the user to loose his unsaved changes.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Data loss on close

Post by wmayer »

The issue is related to issue #0004098
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #4098 - Data loss on close

Post by Kunda1 »

Can anyone tackle this? This is high priority, IMHO.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Ticket #4098 - Data loss on close

Post by jnxd »

So I tried something similar in LibreOffice Writer and this is the error it gives
save-issue-libreoffice.png
save-issue-libreoffice.png (22.82 KiB) Viewed 1349 times
If one clicks "save anyway", LO will save the file in the same exact path, creating any missing folders.

In Evince, GNOME's PDF editor, the application somehow knows whenever the file is edited or even renamed elsewhere, and just starts using the new version instead.

1) I could probably just catch the FileException error and ask the user if they'd like to save the file elsewhere instead. Code-wise the simplest thing to do, but only if FileException is thrown for this specifically.
2) Slightly more difficult, but I could follow LO's way and make the new file if it's missing, maybe adding a third "save as" option as well.
3) I don't know how much effort following Evince's footsteps might be. The solution could end up being platform specific however. I don't know if it'll work on windows/mac.
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Ticket #4098 - Data loss on close

Post by jnxd »

I'm not used to the CLI version but I see the exception comes from deep within App. So I believe if someone tried to delete folders in CLI it would also throw a similar error.
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: Ticket #4098 - Data loss on close

Post by kisolre »

IMO simple is better.
GUI - If there is an exception show meaningful information message with suggested action, return to previous step (save/discard/cancel).
CLI - make good effort to write temporary/intermediate file somewhere, print log message for that (Error writing ...: low disk space. Temp file written under ....).
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Ticket #4098 - Data loss on close

Post by GeneFC »

jnxd wrote: Thu Aug 26, 2021 4:48 am If one clicks "save anyway", LO will save the file in the same exact path, creating any missing folders.
It seems to me this is the best behavior.

It is certainly not standard behavior to change the name of a folder while working on an open file. The program cannot guess why the user did that or what should happen. Recreating the missing folder happens in some other programs. This is the intent-neutral, safest way to proceed.

Gene
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: Ticket #4098 - Data loss on close

Post by kisolre »

GeneFC wrote: Thu Aug 26, 2021 12:55 pm It is certainly not standard behavior to change the name of a folder
If I could reimagine what happened: started a new design. New file in new folder to keep all associated files (IMAGES, STL, FCSTD, ...). Edit fcstd, export stl's, drag stl's to slicer, decide that folder name is not descriptive/concrete/.... enough, rename folder while fcstd is still open (there is no lock mechanism to prevent that), close freecad without realizing that there is now no place to save the modified file.
Being easily distracted is not a crime :)
Post Reply