gpt4 book ai didi

delphi - W10 + Delphi Seattle、TFileOpenDialog + fdoForcePreviewPaneOn = 某些图像崩溃

转载 作者:行者123 更新时间:2023-12-03 15:23:13 42 4
gpt4 key购买 nike

TFileOpenDialog 的预览 Pane 设置似乎存在问题,选择某些图像时应用程序会崩溃。有解决办法吗?

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 的评论,我将实现一个接口(interface)以确保我们始终恢复原始的异常掩码。

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,exDenormalized, exZeroDivide,
exOverflow, exUnderflow, 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.

关于delphi - W10 + Delphi Seattle、TFileOpenDialog + fdoForcePreviewPaneOn = 某些图像崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40965443/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com