小编Sil*_*ior的帖子

在将一些数据输入到动态多维数组后关闭我的应用程序时继续获取AV

我在其中一个项目中遇到了一些奇怪的问题.最奇怪的是,这只发生在这个项目中,我无法在另一个项目中重新创建它.

Luckilly这是一个很小的项目(旨在为SO提供一个问题的答案 - 仍然没有完成)所以我设法弄清楚它必须做什么来破坏我在设计上放置在我的表单上的TImage组件时间并在设计时也为其设置BMP图像.

我得到的AV是:项目Project1.exe引发异常类$ C0000005,消息'访问冲突在0x00407430:读取地址0xfffffffc'.

最后三个调用堆栈是:
Vcl.Graphics.TBitmapCanvas.Destroy
Vcl.Graphics.TCanvasDestroy
System.TObject.Free

此外,Delphi将我置于"Destroy"行的TObbject.Free方法中的System.pas单元中.

procedure TObject.Free;
begin
  if Self <> nil then
{$IFDEF AUTOREFCOUNT}
    __ObjRelease;
{$ELSE}
    Destroy;
{$ENDIF}
end;
Run Code Online (Sandbox Code Playgroud)

此时Self的值仅显示为().

但是为什么只有在我将一些数据存储到我的多维数组中时才会发生这种AV.
我可以在运行时创建和设置多维数组的大小,每一个都很好.但是一旦我更改了这个多维数组中某些项的数据,我就会在关闭应用程序时获得AV.

这是我的完整源代码:

unit Unit2;

interface

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

type
  TSubImage = record
    LeftBound: Integer;
    RightBound: Integer;
    TopBound: Integer;
    BottomBound: Integer;
  end;

  TForm2 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations } …
Run Code Online (Sandbox Code Playgroud)

delphi multidimensional-array dynamic-arrays delphi-xe3

2
推荐指数
1
解决办法
180
查看次数