Fixed: file (or just its folder) stays locked after closing file

Bug reports concerning HxD.
Post Reply
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Fixed: file (or just its folder) stays locked after closing file

Post by Maël »

Quote from a user:
I was viewing a file in hxd and then closed the window. however, hxd still has the file open as I cannot delete the directory that contains this file.

just have hxd running, drop and drag files usually to open them to view, close some, open others, etc... closed this particular one and then needed to delete the folder. pe shows hxd never releases this file.

so, open several files in pe, then close one and then try to delete the folder the last one was in that you closed.

dont know if it matters or not but it was the right most tab that I closed and then tried to delete the folder.

note that the file was able to be deleted in the folder manually, but the folder itself is locked by hxd. don't know if this is related to the backup location you use as still having a handle to the files folder or not. but something in hxd has a handle to the files folder open.
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Re: file (or just its folder) stays locked after closing file

Post by Maël »

Cannot be reproduced in 1.7.7.0 with the details given.

If someone has step by step instructions with the exact action sequence to trigger this bug, it will be reopened.
Homer
Posts: 16
Joined: 22 Aug 2017 16:32

Re: Not reproducible: file (or just its folder) stays locked after closing file

Post by Homer »

Start HxD 2.0.0.0
Drag and drop a file into HxD.
Save as ... and select an existing file in another folder (name "Bug"). Allow overwriting.
Click "x" to close this file.
Unlocker displays that this folder "Bug" is still in use by HxD:
Locked.png
Locked.png (11.02 KiB) Viewed 7236 times
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Re: Not reproducible: file (or just its folder) stays locked after closing file

Post by Maël »

Thanks for the report. Using the latest publicly available download from April 30th, 2017 (http://mh-nexus.de/downloads/HxDSetup.zip), I could not reproduce this bug, unfortunately.
I used LockHunter instead of Unlocker, because the latter was said to contain bundled software and be unmaintained now.

My procedure:
I created the following folder/file structure:
C:\Users\Maël\Desktop\HxDbugtest\folder1
1.txt
b.txt
C:\Users\Maël\Desktop\HxDbugtest\bug
b.txt

I installed HxD as portable in a new folder D:\HxDtest. Opened HxD32.exe per double click. Dragged in D:\HxDbugtest\folder1\b.txt from the explorer.exe window (with C:\Users\Maël\Desktop\HxDbugtest\folder1\ opened). Clicked the menu File|Save as, chose as target D:\HxDbugtest\bug\b.txt confirming to overwrite.
Then I closed the file, pressing x on the top right corner.

I did not change or edit the file before saving, scroll, resize or move any window of HxD (or the save file dialog) before or after save. Just hiding the main window (automatically) when activating the explorer window. I have child windows be maximized by default.


The results are shown in the following screenshot.
hxdlockbug.png
hxdlockbug.png (51.96 KiB) Viewed 7228 times

It might be that the file size is relevant of the dragged and dropped file and the replaced file.
If you could make a quick video, maybe the difference in procedure could be identified.

Thanks.
Homer
Posts: 16
Joined: 22 Aug 2017 16:32

Re: Not reproducible: file (or just its folder) stays locked after closing file

Post by Homer »

Following your description I did install the same version as portable, english language, started 32 bit version and used explorer do drag the file. ... Result: locked.
Locked2.png
Locked2.png (30.1 KiB) Viewed 7221 times
I'm using Windows 7 Ultimate, 64 bit
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Re: file (or just its folder) stays locked after closing file

Post by Maël »

I tried it now in a virtual machine with Win7 32-bit. Still no locks after closing the file.

Edit: I can reproduce it reliably now (under Win7 only), while I could not just a few minutes before. Very odd.
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Re: file (or just its folder) stays locked after closing file

Post by Maël »

I could narrow it down to the following test case:
Open HxD
Use save as or open dialog, choose any file, press ok.

The last folder selected in a file dialog will remain locked.

Edit: Narrowed it down further, it's a Delphi/VCL or a Windows 7 bug.

Using a TFileOpenDialog open dialog (or any other TCustomFileDialog descendant), picking a file and closing it with OK works fine. Doing the same with TOpenDialog triggers the bug (possibly a Windows 7 bug, since the error does not occur on Windows 8 ).

TFileOpen-action uses TOpenDialog internally, and therefore also shows this bug: the last open folder before closing with OK will remain referenced through a handle, until the next time a file dialog is opened and closed with OK.

Summary: TFileOpenDialog works fine, TOpenDialog and TFileOpen-action trigger the bug.
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Re: file (or just its folder) stays locked after closing file

Post by Maël »

The reason for the bug are the disabled themes under Win7.
With disabled themes the VCL/Delphi uses the old file open dialog, which holds onto a folder handle as described. New style file open dialogs do not exhibit this bug and are always displayed when themes are enabled.

So in essence, this is a Windows bug, one of the well known cases where explorer.exe (or its built-in shell services) keeps holding onto files or folders for no obvious reasons. Either this was fixed or lessened in new style open file dialogs. As this is a clean vanilla install of Win7, no third party shell extension can be the cause.

I'll see if I can make the new style file dialogs show when no themes are enabled. The VCL/Delphi does assume themes must be enabled to show them, so there might be a reason...
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Re: file (or just its folder) stays locked after closing file

Post by Maël »

The bug should be fixed in the current release, please try and confirm if it works:
http://mh-nexus.de/downloads/HxDSetup.zip

P.S.: The bug is still a Windows problem, I just alleviated this specific cause by ensuring that the most modern file dialogs are used, even when themes are disabled. There might be other cases where Explorer.exe (or its shell components integrated into HxD) still holds locks longer than necessary, depending on how you use the UI (such as order of operations or type of operations you execute).
Homer
Posts: 16
Joined: 22 Aug 2017 16:32

Re: file (or just its folder) stays locked after closing file

Post by Homer »

It works.
10-HS-3147.jpg
10-HS-3147.jpg (26.57 KiB) Viewed 7162 times
But it works different than before and expected. "Save as" starts in the last "save as"-folder and not in the folder the current file is in. Most of the time I want to use the same folder the current file is in or a folder next to it.
Perhaps you can add the current file's folder as start folder to this dialog.
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Re: file (or just its folder) stays locked after closing file

Post by Maël »

Homer wrote: 24 Oct 2017 04:44 Perhaps you can add the current file's folder as start folder to this dialog.
If the currently open document is already a file on disk, then the "save as"-dialog's initial directory is set to that of this file.
Same link as before contains the updated file.
Homer
Posts: 16
Joined: 22 Aug 2017 16:32

Re: Fixed: file (or just its folder) stays locked after closing file

Post by Homer »

Ok.
0107819.jpg
0107819.jpg (43.84 KiB) Viewed 7135 times
Post Reply