加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

W10 Delphi Seattle,TFileOpenDialog fdoForcePreviewPaneOn =在

发布时间:2020-12-15 09:21:34 所属栏目:大数据 来源:网络整理
导读:TFileOpenDialog的预览窗格设置似乎存在问题,当选择某些图像时应用程序崩溃.有没有解决这个问题? Test image 演示来源: procedure TForm1.Button1Click(Sender: TObject);begin FileOpenDialog1.Execute;end; object FileOpenDialog1: TFileOpenDialog Fav
TFileOpenDialog的预览窗格设置似乎存在问题,当选择某些图像时应用程序崩溃.有没有解决这个问题?

Test image

演示来源:

procedure TForm1.Button1Click(Sender: TObject);
begin
  FileOpenDialog1.Execute;
end;
object FileOpenDialog1: TFileOpenDialog
  FavoriteLinks = <>
  FileTypes = <>
  Options = [fdoForcePreviewPaneOn]
  Left = 200
  Top = 32
end

编辑:它似乎只发生在Windows10(AN.更新)中,在Win7中正常工作.一些调试:

callstack crc      : $6ac33669,$66c06792,$66c06792
exception number   : 1
exception class    : EInvalidOp
exception message  : Invalid floating point operation.

main thread ($ae0):
6ac33669 +000 PhotoMetadataHandler.dll
71f6447f +09f PROPSYS.dll                                   PSCreateDelayedMultiplexPropertyStore
773ef71a +00a combase.dll                                   PropVariantClear
74d317c2 +082 KERNELBASE.dll                                QISearch
71f4f677 +097 PROPSYS.dll                                   #424
71f4f829 +249 PROPSYS.dll                                   #424
6c5f1bba +11a DUI70.dll                                     ?_PreSourceChange@Element@DirectUI@@AAEJPBUPropertyInfo@2@HPAVValue@2@1@Z
6c5ee3a6 +246 DUI70.dll                                     ?_SetValue@Element@DirectUI@@IAEJPBUPropertyInfo@2@HPAVValue@2@_N@Z
6c5ee46e +30e DUI70.dll                                     ?_SetValue@Element@DirectUI@@IAEJPBUPropertyInfo@2@HPAVValue@2@_N@Z
6c5ecf15 +025 DUI70.dll                                     ?SetContentAlign@Element@DirectUI@@QAEJH@Z
6c5e6813 +033 DUI70.dll                                     ?_BroadcastEventWorker@Element@DirectUI@@AAEXPAUEvent@2@@Z
6c5e6867 +087 DUI70.dll                                     ?_BroadcastEventWorker@Element@DirectUI@@AAEXPAUEvent@2@@Z
6c5e68a2 +012 DUI70.dll                                     ?BroadcastEvent@Element@DirectUI@@QAEXPAUEvent@2@@Z
6c5e6813 +033 DUI70.dll                                     ?_BroadcastEventWorker@Element@DirectUI@@AAEXPAUEvent@2@@Z
6c5e6867 +087 DUI70.dll                                     ?_BroadcastEventWorker@Element@DirectUI@@AAEXPAUEvent@2@@Z
6c5e68a2 +012 DUI70.dll                                     ?BroadcastEvent@Element@DirectUI@@QAEXPAUEvent@2@@Z
6c54d590 +0b0 DUser.dll                                     DUserSendEvent
6c5e68ef +03f DUI70.dll                                     ?FireEvent@Element@DirectUI@@QAEXPAUEvent@2@_N1@Z
7529df12 +092 user32.dll                                    CallWindowProcW
752ac53c +0fc user32.dll                                    IsDialogMessageW
752abd8d +02d user32.dll                                    DialogBoxIndirectParamAorW
752abd46 +016 user32.dll                                    DialogBoxIndirectParamW
005af784 +370 Project1.exe             Vcl.Dialogs          TCustomFileDialog.Execute
005af3f9 +045 Project1.exe             Vcl.Dialogs          TCustomFileDialog.Execute
006375ec +008 Project1.exe             Unit1          29 +0 TForm1.Button1Click
005880d3 +073 Project1.exe             Vcl.Controls         TControl.Click
0059f1d2 +01e Project1.exe             Vcl.StdCtrls         TCustomButton.Click
0059fce0 +010 Project1.exe             Vcl.StdCtrls         TCustomButton.CNCommand
00587b65 +2bd Project1.exe             Vcl.Controls         TControl.WndProc
0058c6a5 +5e9 Project1.exe             Vcl.Controls         TWinControl.WndProc
0059ee7c +06c Project1.exe             Vcl.StdCtrls         TButtonControl.WndProc
005877a0 +024 Project1.exe             Vcl.Controls         TControl.Perform
0058c80b +023 Project1.exe             Vcl.Controls         DoControlMsg
0058d293 +00b Project1.exe             Vcl.Controls         TWinControl.WMCommand
00627ed9 +045 Project1.exe             Vcl.Forms            TCustomForm.WMCommand
00587b65 +2bd Project1.exe             Vcl.Controls         TControl.WndProc
0058c6a5 +5e9 Project1.exe             Vcl.Controls         TWinControl.WndProc
00624d08 +62c Project1.exe             Vcl.Forms            TCustomForm.WndProc
0058bcc4 +02c Project1.exe             Vcl.Controls         TWinControl.MainWndProc
0052f48c +014 Project1.exe             System.Classes       StdWndProc
77630004 +034 ntdll.dll                                     KiUserCallbackDispatcher
752a0bfb +13b user32.dll                                    SendMessageW
7529df12 +092 user32.dll                                    CallWindowProcW
0058c7b6 +0e6 Project1.exe             Vcl.Controls         TWinControl.DefaultHandler
00588528 +010 Project1.exe             Vcl.Controls         TControl.WMLButtonUp
00587b65 +2bd Project1.exe             Vcl.Controls         TControl.WndProc
0058c6a5 +5e9 Project1.exe             Vcl.Controls         TWinControl.WndProc
0059ee7c +06c Project1.exe             Vcl.StdCtrls         TButtonControl.WndProc
0058bcc4 +02c Project1.exe             Vcl.Controls         TWinControl.MainWndProc
0052f48c +014 Project1.exe             System.Classes       StdWndProc
7529df9b +00b user32.dll                                    DispatchMessageW
0062e363 +0f3 Project1.exe             Vcl.Forms            TApplication.ProcessMessage
0062e3a6 +00a Project1.exe             Vcl.Forms            TApplication.HandleMessage
0062e6d9 +0c9 Project1.exe             Vcl.Forms            TApplication.Run
00640801 +049 Project1.exe             Project1       18 +4 initialization
74fa62c2 +022 KERNEL32.DLL                                  BaseThreadInitThunk

disassembling:
006375e4    public Unit1.TForm1.Button1Click:  ; function entry point
006375e4 29   mov     eax,[eax+$3c4]
006375ea      mov     edx,[eax]
006375ec    > call    dword ptr [edx+$4c]
006375ef 30   ret

解决方法

您正在看到源自PhotoMetadataHandler.dll的FPU异常,它崩溃的原因尚不清楚,但似乎某些JPG文件可能导致浮点异常.例如Total Commander(用Delphi编写)遇到了同样的问题 a number of times.
修复非常简单,在执行对话框之前禁用所有异常并在之后重新启用它们:

procedure TForm1.Button1Click(Sender: TObject);

var
  OrgMask : TArithmeticExceptionMask;

begin
 OrgMask := GetExceptionMask;
 // disable all exceptions
 SetExceptioNMask([exInvalidOp,exDenormalized,exZeroDivide,exOverflow,exUnderflow,exPrecision]);
 FileOpenDialog1.Execute;
 SetExceptionMask(OrgMask);
end;

编辑

基于Craig Young的评论,我将实现一个接口,以确保我们始终恢复原始异常掩码.

unit Unit1;

interface

uses
  Winapi.Windows,Winapi.Messages,System.SysUtils,System.Variants,System.Classes,Vcl.Graphics,Vcl.Controls,Vcl.Forms,Vcl.Dialogs,Vcl.StdCtrls,System.Math;

type
  ICatchAllFPUExceptions = interface
  ['{7F429ECA-B458-4F39-832B-429839A8E948}']
  end;

  TCatchAllFPUExceptions = class(TInterfacedObject,ICatchAllFPUExceptions)
  private
    OrgExceptionMask : TArithmeticExceptionMask;
  public
    class function Activate : ICatchAllFPUExceptions; static;
    constructor Create;
    destructor Destroy; override;
  end;

  TForm1 = class(TForm)
    FileOpenDialog1: TFileOpenDialog;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TCatchAllFPUExceptions }
class function TCatchAllFPUExceptions.Activate: ICatchAllFPUExceptions;
begin
 Result := TCatchAllFPUExceptions.Create;
end;

constructor TCatchAllFPUExceptions.Create;
begin
 inherited;
 OrgExceptionMask := GetExceptionMask;
 SetExceptioNMask([exInvalidOp,exPrecision]);
end;

destructor TCatchAllFPUExceptions.Destroy;
begin
 SetExceptioNMask(OrgExceptionMask);
 inherited;
end;

procedure TForm1.Button1Click(Sender: TObject);       
begin
 // disable all exceptions
 TCatchAllFPUExceptions.Activate;     
 FileOpenDialog1.Execute;
 // mask will be restored here due to internal function variable going out of scope
end;

end.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读