通用定义在单元中断调试信息 [英] Generic defined in unit breaking debug information

查看:238
本文介绍了通用定义在单元中断调试信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这必须是一个Delphi错误...

This must be a Delphi bug...

我有一个单位是我的持久性框架的基础。在该单元中,我有一个基类,用于所有域对象,列表类和通用列表类。

I have a unit which is the basis of my persistance framework. In that unit I have a base class for all my domain objects, a list class and a generic list class.

刚刚注意到,当我进入单元时调试,执行会跳到一点点在文件中比它应该更多一些...也许四五行。重新排序文件没有任何区别。代码也会产生访问冲突,但是只有当我调试它时。

Just recently I noticed that when I step into the unit when debugging, execution will jump to a point a little further down in the file than it should... Maybe four or five lines. Re-ordering the file makes no difference. The code would also generate access violations, but only when I debugged it.

我投入了试图找到原因...有几件事情想到,像一些使用调试器的代码注入(例如,此logitec网络摄像头驱动程序错误)或调试信息与我的单位来源不同步(例如,dcu从一些旧的来源被拉)。

I cast about trying to find the reason for this... Several things came to mind, like some code injection screwing with the debugger (eg this logitec webcam driver bug), or the debug info being out of sync with my unit source (eg the dcu was being pulled from some old source).

最后,我用一个干净的Windows + Delphi安装,只抓住我需要测试的单位,我创建了一个小型的DUnit项目来测试它。相同的问题。

In the end I fired up a VM with a clean Windows + Delphi install, grabbed only what I needed to test the unit, and I created a small DUnit project to test it. Same problem.

然后,我一次一个地从单元中删除东西,直到它工作。唯一有区别的是当我删除通用列表类时。

Then I started removing things from the unit one at a time till it worked. The only thing that made any difference was when I removed the generic list class.

有没有人看到这个问题?有人知道如何解决吗?

Has anyone else seen this problem? Does anyone know how to get around it?

提前感谢

N @

更新:将通用回调添加到本机中会导致问题回来,所以不是过时的DCU的问题。

Update: Adding the generic back into the unit makes the problem come back, so it's not a problem of stale DCUs.

推荐答案

最后,我可以找到的唯一解决办法是将通用列表移出单位。

In the end, the only solution that I could find that worked was to move the generic list out of the Unit.

更新2011-08-03 更好地解决我的解决方案:

Update 2011-08-03 To better flesh out my solution:

我的通用列表基类定义在我的单位与我的基础 TDomainObject 类和非泛型版本。

I had my generic list base class defined in my Domain unit with my base TDomainObject class and a non-generic version.

为了解决这个问题,我将泛型转移到第二个 Domain.Generics 单元中,解决了我的问题。

To fix the problem, I moved the generic into a second Domain.Generics unit which resolved the problem for me.

所以:

unit Domain;

interface 

type
  TDomainObject = class
    //blah de blah
  end;

  TDomainObjectList = class (TDomainObject)
    //more stuff
  end;

  TDomainListEnumerator = class
    //etc
  end;

And:

unit Domain.Generics;

interface

type

  TDomainObjectList<T: TDomainObject> = class (TDomainObjectList)
    //stuff
  public
    property Items[AIndex: integer]: T read GetItem write SetItem;

    type
      TEnumerator = class (TDomainListEnumerator)
      public
        function GetCurrent: T;
        property Current: T read GetCurrent;
      end;

  public
    function GetEnumerator: TEnumerator;

  end;

这篇关于通用定义在单元中断调试信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆