Page 1 of 1

Preview (Font) Delete Error

Posted: 17 Nov 2011 19:55
by Zardoz2293
Concern:
Deleting FONT file in LV with PREVIEW active, displaying the font contents results in 'file in use' error.

Occurrence (Modified: 2011-11-18)
1. 100% of the time. Easy to reproduce; (When whatever conditions exist to cause it :oops: ) OR
2. ?% of the time. Might be tricky to reproduce after all.

Procedure:
1. Display font file in LV with Preview active.
2. Font is displayed in the preview.
3. Press DEL (delete).
4. Preview display of font is removed.
5. Dialog "Are you sure you want to move this file to the Recycle Bin?" appears.
6. Respond: Yes
7. Dialog "The action can't be completed because the file is open in another program..."

Expected Behavior:
1. File deleted, no error dialog message.

Workaround:
1. Deselect the font file as current item in LV. (various methods)
2a. Right-click font file select 'Delete"; OR
2b. Deactivate Preview then select font file and delete.

Re: Preview (Font) Delete Error

Posted: 17 Nov 2011 20:15
by zer0
That's not a bug. Previewing a file involves opening it, which means putting it "in use".

Re: Preview (Font) Delete Error

Posted: 17 Nov 2011 20:36
by avsfan
zer0 wrote:That's not a bug. Previewing a file involves opening it, which means putting it "in use".
True, although with some other file formats (not sure which ones), I believe XY essentially closes the preview before attempting to delete the file (taking the file out of use), and there is no error.

Sounds to me like this could benefit from the same program flow... In fact, wouldn't it make sense to have *any* open preview closed when trying to delete that file? EDIT: Or does it always do that anyway (or supposed to, anyway)?

Re: Preview (Font) Delete Error

Posted: 17 Nov 2011 20:52
by Zardoz2293
zer0 wrote:That's not a bug. Previewing a file involves opening it, which means putting it "in use".
When the delete is pressed the preview display image is removed. Therefore one would assume the handle has been released. Is the claim that if you preview and display the contents of a file that you cannot performed a delete of that file by turning the preview to display nothing, releasing the handle of the file or releasing the object handle you called to display the contents, in the case of an external third-party component? Been doing it for over two decades. It's a bug in the presented paradigm. If it retained the preview display image when the delete was pressed it would be an enhancement request.

Re: Preview (Font) Delete Error

Posted: 18 Nov 2011 08:57
by admin
According to my tests this has nothing to do with the preview. The problem appears when a font is currently activated in Windows. The font name in the info section of the font preview is marked blue if this is the case. You cannot delete such a font file in any application.

Re: Preview (Font) Delete Error

Posted: 18 Nov 2011 23:04
by Zardoz2293
admin wrote:According to my tests this has nothing to do with the preview. ... You cannot delete such a font file in any application.
I've conducted testing myself and found it directly related to the 'preview' causing the font to remain active. I don't know if it was a GDI+ handle still active or what going on behind the curtain. I just did a quick test right now and I can't reproduce. I was using v10.50.0025 at the time now 0027 (not claiming an association). The font was displayed in black at first then it turned blue during the inability to delete (black > delete > blue). However, removing the 'preview' out of the equation resolved the problem consistently when the 'event' had occurred. There were no other applications taking a hold on the font other than XY. I had been using XY extensively with the same session (w/o app recycling) when it occurred (I'd experienced the anomaly on at least 5 other sessions). I'll update my original posting for the 'occurrence' statement and keep an eye out for what conditions could possibly be contributing, including even if I'm the cause and not XY.

UPDATE: 2011-11-18 @1617
Don, I've discovered the cause and other associated variances in behavior with the deleting of a font from within XY. Before I post my findings I have a question: What exactly does clicking on the field "Font name:" Activate/Deactivate perform? Thanks!

Re: Preview (Font) Delete Error

Posted: 21 Nov 2011 13:59
by admin
Zardoz2293 wrote: What exactly does clicking on the field "Font name:" Activate/Deactivate perform? Thanks!
Call API AddFontResource resp. RemoveFontResource (toggle).

Re: Preview (Font) Delete Error

Posted: 23 Nov 2011 22:40
by Zardoz2293
admin wrote:
Zardoz2293 wrote: What exactly does clicking on the field "Font name:" Activate/Deactivate perform? Thanks!
Call API AddFontResource resp. RemoveFontResource (toggle).
Several observations and two different approaches (#s as reference for discussion only):
  • 1. I'm proposing some concept of label 'Font name" field data: "Blue" = Active, "Black" = Not Active, and a 3rd "Red" = Clone (like green but color blind men wouldn't be able to tell Blue/Green); Clone is defined in this statement as being a copy of or the original, it isn't relevant, but simply an exact copy of the 'other' file, both existing at the same time.

    2. Assuming XY "Activate" will never "Install" the font -- Displayed "Font name:" in blue, this may or may not be correct from the perception of the location of the font file. If the font has been "Installed" a copy (clone) of it was put into the %SystemRoot%\Fonts folder. Examining 'active' font location vs. 'current' previewed font file would determine "Blue" = Active or "Red" = Clone. The "Red" (displayed in "Blue" today) status is why I'm experiencing the dialog below. Status could be determined by: (1) Performing RemoveFontResource if successful you know this "is" the font file (not registered in %SystemRoot%\Fonts), then AddFontResource to restore, status = "Blue", (or perform binary compare), all preprocessed before display. If RemoveFontResource fails you know you have a cloned font file (registered in %SystemRoot%\Fonts), status = "Red".

    3. Activating / Deactivating Font from XY causes an interesting event to occur: You cannot "see" the XY Activated font as registered from within the Windows (W7) "Control Panel | Appearance and Personalization | Fonts" (as a copy isn't put into the font folder on XY "Activate").

    4. This is why: (Preview Active) You can DELETE an "Active (Blue)" font file and be surprised it would delete (Installed and a Clone). The font file is still active/registered in the system, just the clone was deleted (what you see directly in the XY List View). I'd expect to have the two font files verified as binary the same, if so, Deactivated & Deleted (both copies).

    5. If "Active (Blue)" and (not Installed and it isn't a Clone) you cannot delete. Seems to be the Font can be Deactivated and then deleted, this would of course require after the "Delete" request event the file type was identified and then if a font deactivated and then deleted. Some will argue why? But if so, then shouldn't the behavior be consistent with "Installed" fonts when the files are identical?
    ~
  • 6. Assuming XY "Activate/Deactivate" performs "Install/Delete" of font. Work exactly like Windows Fonts would Install or Delete the %SystemRoot%\Font copy and retain the local copy font file.
    ~
    UPDATED: (Modified: 23-11-2011 @1429)
  • 7. Activate. Rename Font File. Deactivate. "Failed" msg. Seems all of the above would be resolved via Installing/Deleting from %SystemRoot%\Fonts rather than just current folder.
Yes, I know I expect much, but I always do from the best.

Re: Preview (Font) Delete Error

Posted: 02 Dec 2011 12:29
by admin
Thanks for your suggestion. I'm currently not working in this area of the app. And it might be a bit too much to ask. ;)