Bug 80776

Summary: FILEOPEN: read-only keeps file open
Product: LibreOffice Reporter: pb <blicher>
Component: UIAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: enhancement CC: ilmari.lauhakangas, raal
Priority: medium    
Version: 4.2.5.2 release   
Hardware: Other   
OS: Windows (All)   
Whiteboard: BSA
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 108882    

Description pb 2014-07-01 23:54:36 UTC
Observed in Calc with xls file;  I did not look at other components.

If a file is opened in read-write mode (the default), then toggled to read-only (using the 'edit file' button, the file is still kept open (now apparently in read-only mode) (based on my observations using sysinternals process explorer).  As far as I can tell, there is no need to keep a read-only mode file open once it has been read in.  However, there is a good reason to close it once it has been read in.  Namely, Windows 7 (and no doubt later versions) will not permit a machine to sleep if it has a file opened across the network.

Meanwhile, it appears that if a file is initially opened in read-only mode (by checking the read-only check box in the open dialog), then the file is closed once it has been opened and read.

If my observations are correct, then this is inconsistent behavior, and when a file is toggled from read-write to read-only, the file should then be closed.
              
Operating System: Windows 7
Version: 4.2.5.2 release
Comment 1 raal 2015-04-05 20:27:53 UTC
Hello,
in sysinternal I doesn't see a difference between read only and normal file, but it's probably because I don't know what to watch. Please describe your observations. Thank you
Comment 2 pb 2015-04-05 20:34:13 UTC
(In reply to raal from comment #1)
> Hello,
> in sysinternal I doesn't see a difference between read only and normal file,
> but it's probably because I don't know what to watch. Please describe your
> observations. Thank you

I'm not sure what you mean by "see a difference between read only and normal file"?

If the file is read-only, calc does not need to keep an open file handle to it after it has read it in, hence it should not even show in process explorer.
Comment 3 raal 2015-04-06 11:04:27 UTC
Finally I've found where to see open files in sysinternals..

I can confirm with Version: 4.5.0.0.alpha0+
Build ID: ea59d42d2098e8be8b3ab9667922e8427ee4b714
TinderBox: Win-x86@42, Branch:master, Time: 2015-03-23_01:47:57
file type xlsx, ods.

In linux I doesn't see this behaviour, after set Edit/read only is lsof command empty.