View Issue Details

IDProjectCategoryView StatusLast Update
0002666FreeCADBugpublic2016-08-12 11:35
Reporterpaulcquinn Assigned To 
PriorityurgentSeveritymajorReproducibilitysometimes
Status closedResolutionfixed 
PlatformMS WindowsOS7OS Version64 bit Windows 7
Product Version0.16 
Fixed in Version0.17 
Summary0002666: Error on Save File
DescriptionWhen select save file it comes up with an error message saying it can not save the file.
This happens about 75% of the times, the other 25% it will save the file without error.
Steps To ReproduceStart FreeCAD, create a simple model, click save command. Then it will either save the file or come back with the error message that it can not save.
TagsNo tags attached.
FreeCAD Information

Relationships

duplicate of 0002245 closedwmayer BRep File cannot be written 

Activities

paulcquinn

2016-08-09 14:14

reporter  

FreeCAD Error 02.jpg (Attachment missing)

wmayer

2016-08-11 10:49

administrator   ~0007259

See also: http://forum.freecadweb.org/viewtopic.php?f=3&t=16859&p=133249&hilit=directaccess#p133249

No idea how it happens that the write operation fails but it must be a problem in the OCC library which we have no control over.

As workaround try this:
> In order to activate this go to the parameter editor and create under "BaseApp/Preferences/Mod/Part/General" the boolean key "DirectAccess" and set it to true.

paulcquinn

2016-08-11 13:48

reporter  

FreeCAD Saved Files 02.jpg (Attachment missing)

paulcquinn

2016-08-11 14:01

reporter   ~0007260

Thank you for your reply. I have tried what you suggested but it has not worked. I still get the save error more often than not.
I would like to ask about FreeCAD save file structure. When I save a model file in a folder it saves what I would call a normal file and a backup copy, but it also saves strange very long files with random letters and numbers. What are these files and what is the BRep file 'C:/Users/cadman/AppData/Local/Temp/FCTD6AE.tmp' which it can not save?
I have attached a Screen Shot of the files in my save folder.
Thank You,

wmayer

2016-08-11 17:19

administrator   ~0007263

> Thank you for your reply. I have tried what you suggested but it has not worked. I still get the save error more often than not.
Then you didn't set the key on the right place because otherwise it doesn't print any errors at all.

This is the part of the source code where to write the brep files:
https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Part/App/PropertyTopoShape.cpp#L286

In case DirectAccess is set correctly this part is getting executed: https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Part/App/PropertyTopoShape.cpp#L336

The save strategy works this way:
* If you already saved a project, it first creates a new file with a GUID as suffix. This is because if we overwrote the file directly it may happen that it fails and then you would lose all your data.
* If the save succeeds we rename the old project file with a number e.g. FCStd1 if backup files are enabled or delete it if not
* then the file above with the GUID is renamed to the original file

If the files with the GUID can't be renamed then there must be another process accessing the original file.

But all this has nothing to do with the failure to save the brep files.

When saving a brep file there are two possible ways:
1. make a tmp. file, open the file and copy its contents into the project file (which is a normal zip file)
2. write it directly to the zip file (see DirectAccess)

By default we use the method 1.) because if the OCC library is build with a different compiler version than FreeCAD then method 2.) will crash (this is caused by a binary incompatibility of C++ streams and is not fixable).

paulcquinn

2016-08-11 20:37

reporter   ~0007264

Last edited: 2016-08-11 21:05

Thank you for your reply.

I have just checked and I did not set the key "DirectAccess" in the right place.
I have now set it in the correct place and the Save command works O.K. now.

Thank you very much for your help.

wmayer

2016-08-12 08:21

administrator   ~0007265

No idea why method 1.) fails that often. There are actually only two kind of users: those for which it happens all the time and those for which it never happens. Not sure if this could be related to the hard disk or some system limitations.

The relevant part of the OCC lib is this and since the files are empty it must already fail when trying to open them.

Standard_Boolean  BRepTools::Write(const TopoDS_Shape& Sh, 
                                   const Standard_CString File,
                                   const Handle(Message_ProgressIndicator)& PR)
{
  ofstream os;
  OSD_OpenStream(os, File, ios::out);
  if (!os.rdbuf()->is_open()) return Standard_False;

  Standard_Boolean isGood = (os.good() && !os.eof());
  if(!isGood)
    return isGood;
  
  BRepTools_ShapeSet SS;
  SS.SetProgress(PR);
  SS.Add(Sh);
  
  os << "DBRep_DrawableShape\n";  // for easy Draw read
  SS.Write(os);
  isGood = os.good();
  if(isGood )
    SS.Write(Sh,os);
  os.flush();
  isGood = os.good();

  errno = 0;
  os.close();
  isGood = os.good() && isGood && !errno;

  return isGood;
}

Anyway, I will now make method 2.) the default because nowadays the possible binary incompatibility of the C++ streams is not such a big issue any more since for Windows we offer the libpacks where everything is built with the same compiler and on Linux it's not a problem anyway when using the packages from the repositories.

Related Changesets

FreeCAD: master 006de1ab

2016-08-12 13:33:48

wmayer

Details Diff
issue 0002666: Error on Save File Affected Issues
0002666
mod - src/Mod/Part/App/PropertyTopoShape.cpp Diff File

Issue History

Date Modified Username Field Change
2016-08-09 14:14 paulcquinn New Issue
2016-08-09 14:14 paulcquinn File Added: FreeCAD Error 02.jpg
2016-08-11 10:49 wmayer Note Added: 0007259
2016-08-11 13:48 paulcquinn File Added: FreeCAD Saved Files 02.jpg
2016-08-11 14:01 paulcquinn Note Added: 0007260
2016-08-11 17:19 wmayer Note Added: 0007263
2016-08-11 20:37 paulcquinn Note Added: 0007264
2016-08-11 21:05 paulcquinn Note Edited: 0007264
2016-08-12 08:21 wmayer Note Added: 0007265
2016-08-12 11:34 wmayer Changeset attached => FreeCAD Master master 006de1ab
2016-08-12 11:35 wmayer Relationship added duplicate of 0002245
2016-08-12 11:35 wmayer Status new => closed
2016-08-12 11:35 wmayer Resolution open => fixed
2016-08-12 11:35 wmayer Fixed in Version => 0.17