DiscussionsIssue archiveOCCT:Foundation Classes

Archived issue #0026381

OSD_File - close file on destruction

Open CASCADEOCCT:Foundation Classesclosed14 public notes

Search issues

Description

Current implementation of OSD_File keeps file opened on destruction which might lead to memory leaks or file locks.

Since this behavior is unusual (e.g. std::ofstream closes file on destruction) it would be better to fix this to avoid possible errors.

Steps to reproduce

Not required

Public activity

14 archived notes

Participants are labeled by their role within this record.

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

[revision removed]


Detailed log of new commits:

Author: akz
Date: Fri Sep 25 13:44:41 2015 +0300

    0026381: OSD_File - close file on destruction
    
    Add destructor for OSD_File, that unlocks and close file.
02Commenter 2
Branch CR26381 is ready for review
03Author
I suppose that the following check:
764 Standard_Boolean OSD_File::IsOpen()const{
765
766  if (myPath.Name().Length()==0)
767    Standard_ProgramError::Raise("OSD_File::IsOpen : empty file name");

might lead to exception during destruction of empty OSD_File.
04Commenter 4
Is this check kind of linux specific? Cause code for windows does not contain such check in the same functions.
IsOpen() anyway returns False, if file path is empty. Do we really need to throw exception here?

05Commenter 5
I believe raising exception there is senseless and should be removed
06Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
07Commenter 7
Senseless checks were removed from IsOpen(), IsLocked() and GetLock().
Branch CR26381 was updated.

08Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: abv
Date: Fri Sep 25 19:27:25 2015 +0300

    Destructor of OSD_FileNode is made protected to avoid possibility of deleting descendants by pointer to base class

09Commenter 9
Reviewed and corrected; please test
10Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
11Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
12Commenter 12
Branch [archived branch] has been rebased on the current master
13Commenter 13
Dear Commenter 1,

Branch CR26381 from occt git-repository (and master from products git-repository) was compiled on Linux and Windows platforms and tested.
[revision removed]

Number of compiler warnings:
occt component:
   Linux: 13 (13 on master)
   Windows: 0 (0 on master)
products component:
   Linux: 39 (39 on master)
   Windows: 0 (0 on master)

Regressions/Differences:
Not detected

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 93373001 / 93274110 [+0.11%]
Total CPU difference: 19437.86999999933 / 19594.749999999236 [-0.80%]

Testing on Windows:
Total MEMORY difference: 57926411 / 57934407 [-0.01%]
Total CPU difference: 17980.987261999133 / 17727.251635499077 [+1.43%]
14Commenter 2
Branch [archived branch] has been deleted by Author.

[revision removed]