DiscussionsIssue archiveOCCT:Application Framework

Archived issue #0027433

Opening/Saving OCAF Documents With Own Document Format Does Not Work

CommunityOCCT:Application Frameworkclosed17 public notes

Search issues

Description

I am using an own OCAF document format named "Compositence" and I have two files
"Compositence" and "Plugin" in my resource folder. I initialize two environment variables "CSF_PluginDefaults" and "CSF_CompositenceDefaults" both pointing to that resource folder.

When I want to open an OCAF document or create an instance of TDocStd_Application, a Standard_OutOfRange error is raised in OSD_Path::DownTrek, because the name aName passed to this function is empty.

To me it seems as if the error happened in Resource_Manager.cxx around line 489. There the commands

  OSD_Path anOSDPath(aResPath);
  anOSDPath.DownTrek(anOSDPath.Name());
  anOSDPath.SetName(aName);

are executed. According to the paragraph "Saving the document" in the section "Standard Document Services" of the OCCT OCAF documentation, it is correct to store only the resource folder name in the environment variables. Therefore anOSDPath.Name() must return an empty string, since there is no file name. Then the method DownTrek may not be called with anOSDPath.Name(). Anyway, why should the file name of anOSDPath added to the path?

My environment variables and code have worked at least until OCC 6.8.0. Later OCC versions I have not checked, but with OCC 7.0.0 they don't work anymore.

Steps to reproduce

Open a file in your own format after setting CSF_PluginDefaults and CSF_FormatDefaults to the respective directories.

Public activity

17 archived notes

Participants are labeled by their role within this record.

01Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Benjamin Bihler
Date: Thu Apr 28 13:18:35 2016 +0200

    0027433: Opening/Saving OCAF Documents With Own Document Format Does Not Work
    
    Modified Load(...) method of Resource_Manager.cxx to print file names correctly.
02Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Benjamin Bihler
Date: Thu Apr 28 15:58:56 2016 +0200

    0027433: Opening/Saving OCAF Documents With Own Document Format Does Not Work
    
    Removed appending (empty) file name to directory name, since this is not
    necessary and leads to a Standard_OutOfRange failure in TCollection_AsciiString.

03Author
mpv, I have removed the call to DownTrek. With that change everything works here as expected. Since you have not commented yet, I have commited that and marked the issue as resolved. Would you check it please? Thank you!
04Commenter 4
Hello Benjamin,

I see your fix and I think it's ok. To be save I would prefer something like

if (!anOSDPath.Name().IsEmpty())
  anOSDPath.DownTrek(anOSDPath.Name());

but, I'm not sure is this DownTreck needed or not.

So, as soon I will see all the possible cases (and found why this line is appeared here), I will approve this commit. I hope, it will take not a lot of time.
05Author
Hello mpv,

did you have the possibility to check it?

Your proposal is okay for me, of course. If you cannot check soon, whether DownTrek can be omitted completely, shall I commit the if-clause?

Benjamin
06Commenter 6
Hello Benjamin,

I found both cases it is reproduced. The OSD_Path implementation is quite simple. It gets as name everything that is after last "/" symbol.
So, for path
C:/aaa
the name is "aaa" and it must be added to the folder,
but for
C:/aaa/
the name is empty. As I understand, this is your case.

Anyway, crash because of "/" symbol in the end of path is very bad and I agree that this should be fixed. But "if-clause" is needed to cover all cases.

So, could you integrate the fix with "if-clause" and check that in your case it works?
07Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Benjamin Bihler
Date: Wed May 4 14:48:02 2016 +0200

    0027433: Opening/Saving OCAF Documents With Own Document Format Does not Work
    
    Appending file name is done, but only if the name is not empty.

08Author
I have checked it already. Like that it works for me.
09Author
... and yes, you are right - my paths have ended with "/". :-)
10Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: mpv
Date: Thu May 5 13:30:03 2016 +0300

    0027433: Opening/Saving OCAF Documents With Own Document Format Does Not Work
    
    Added unit tests

11Commenter 11
Test case bugs/caf/bug27433 has been pushed to branch CR27433.
12Commenter 12
Reviewed.
To be tested.
13Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
14Commenter 14
Dear Commenter 1,
Branch CR27433 was rebased on current master of occt git-repository.
[revision removed]
15Commenter 15
Dear Commenter 1,
Branch CR27433 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]

Number of compiler warnings:

occt component :
Linux: 0 (0 on master)
Windows: 0 (0 on master)
MacOS : 0 (0 on master)

products component :
Linux: 72 (72 on master)
Windows: 4 (4 on master)
MacOS : 1132

Regressions/Differences/Improvements:
No regressions/differences

Testing cases:
http://occt-tests/CR27433-master-OCCT/Debian70-64/bugs/caf/bug27433.html
http://occt-tests/CR27433-master-OCCT/Windows-64-VC10/bugs/caf/bug27433.html
bugs caf bug27433: OK

Testing on Linux:
occt component :
Total MEMORY difference: 87713780 / 87496177 [+0.25%]
Total CPU difference: 19321.39000000006 / 19371.120000000185 [-0.26%]
products component :
Total MEMORY difference: 27869122 / 27830579 [+0.14%]
Total CPU difference: 5361.219999999987 / 5343.229999999986 [+0.34%]

Testing on Windows:
occt component :
Total MEMORY difference: 55515772 / 55543634 [-0.05%]
Total CPU difference: 18215.129162898742 / 18267.951101498817 [-0.29%]
products component :
Total MEMORY difference: 18922510 / 18891436 [+0.16%]
Total CPU difference: 5079.7045619999535 / 5013.591338199941 [+1.32%]

There are no differences in images found by testdiff.
16Commenter 16
Dear Commenter 1,
Branch CR27433 is TESTED.
17Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]