在 Delphi 中添加单位或新表格会导致访问冲突

Adding an Unit or New Form in Delphi causes Access Violation

当我将文件或表单添加到 Delphi 项目时,我经常遇到访问冲突。那我只好重启Delphi,打开项目再试一次。然后它有时会起作用,有时我会遇到相同的访问冲突。自 XE8 以来,我在所有 Delphi 版本中都遇到了这个问题。

其他 Delphi 程序员似乎也有同样的问题,如在 Embarcadero 社区中:https://community.embarcadero.com/forum/programming/9387-creating-a-new-unit-or-new-form-in-delphi-10-2-3-causes-access-violation

有人说是第三方库造成的。我不信。查看堆栈跟踪时,没有第三方库。

重现:

我就此联系了 Embarcadero。他们知道这个问题并回复如下:

It's due to some Castalia code, that's merged in Delphi since XE8. It's only possible to reduce this issue, so it will happen less often. Use: Tools - Options - Editor Options - Color - Structural Highlighting and switch everything off.

Looking at how the code is integrated into the IDE, this results in less editor parsing and repainting. Irrespective of that, the handler that causes the Access violation is still attached to the editor.

So basically, we will have to wait for this to be fixed in 10.3.

但过了一会儿,我发现只有在关闭项目 'dpr file' 时才会发生访问冲突。因此,作为解决方法:

不要关闭 dpr 文件,您将不会遇到访问冲突