为什么在Delphi中添加Action会导致致命错误

发布于 2024-09-12 06:48:04 字数 936 浏览 12 评论 0原文

我使用的是Delphi 2009。我的程序编译并运行良好。我使用操作列表并将它们内置到我的程序中 - 尽管我已经有一段时间没有更改它们了。

因此,今天我将按照正常方式简单地将一个新操作添加到我的 ActionList 中。在不做任何其他事情的情况下,我现在构建并运行我的程序,并收到以下错误:

[DCC Fatal Error] Userface.pas(1): F2092 程序或单元“Userface”递归地使用自身。

我没有做任何改变任何使用条款。我找不到我的 Userface 单元调用自身或调用另一个调用 Userface 的单元的任何实例。我将潜在的递归调用按其应有的方式放置在“实现”部分中。

如果我退出 Delphi 而不保存、重建并运行它,它运行得很好。如果我再次尝试将新操作添加到操作列表中,则会再次发生致命错误。

我不知道发生了什么。我将不胜感激任何帮助找出如何解决这个问题。


编辑:乌韦回答后,我仔细检查以确保它仍在发生。果然,我按照我在给乌韦的评论中描述的那样又做了一次。建好之后,又出现了这样的情况。

...但是后来,在项目菜单下,我意外地错过了选择“构建”并选择了“编译”。它编译得很好。然后我尝试构建,现在构建工作正常。没有致命错误!对我来说一切似乎又都很好了。

如果我尝试添加另一个操作然后构建,则会再次出现错误。但如果我编译,那么我可以成功构建它 - 所以至少我有一个解决方法。

这一定是某种故障。我不知道发生了什么事。有谁知道这是什么或者为什么会发生?


跟进。正如马里安所说,这种情况也可能发生在其他情况下,其中之一就发生在我身上。所以它可能与我的问题所要求的添加操作没有直接关系。

尽管如此,到目前为止,这种情况对我来说还是比较罕见的,而且只是一个小烦恼。它可能已经在 Delphi 2010 中得到修复,我的最终解决方案将是当我下次升级到 Delphi 2011 或 12 时,一旦它们添加了 64 位或多平台。

I'm using Delphi 2009. My program has been compiling and running fine. I use Action lists and have them built into my program - although I haven't changed them in a while.

So today I go to simply add a new action to my ActionList in the normal manner that it is done. Without doing anything else, I now build and run my program and I get the following error:

[DCC Fatal Error] Userface.pas(1): F2092 Program or unit 'Userface' recursively uses itself.

I have done nothing to change any of the uses clauses. I can't find any instances of my Userface unit calling itself or calling another unit that calls Userface. I place potentially recursive calls in the Implementation section as they should be.

If I exit Delphi without saving, rebuild and run it, it runs fine. If I attempt again to add a new action to the action list, the fatal error happens again.

I'm at a loss to figure out what is happening. I would appreciate any help to figure out how to get around this.


Edit: After Uwe's answer, I double checked to make sure it was still happening. Sure enough, I did it again as I described in my comment to Uwe. After building, it happened again.

... But then, by accident under the Project Menu I missed picking "Build" and selected "Compile" instead. It compiled fine. Then I tried building and now the build works correctly. No Fatal Error! Everything seems fine for me again.

If I try to add another action and then build, the error comes up again. But if I compile, then I can build it successfully - so at least I have a workaround.

This must be some sort of a glitch. I don't know what happened. Does anybody know what this is or why it might be happening?


Followup. As Marjan states, it can occur in other circumstances, and one of those happened to me. So it is probably NOT directly related to the adding an action, which my question asks.

None-the-less, it is a relatively rare happening so far for me and has only turned into a minor annoyance. It may already have been fixed in Delphi 2010, and my ultimate solution will be when I next upgrade to Delphi 2011 or 12 once they add either 64-bit or multi-platform.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小苏打饼 2024-09-19 06:48:04

如果您绝对确定编译了正确的源代码(.dpr 路径!)并且使用部分相同,那么如果非常简单或未使用,Delphi 可能可以消除相互引用。

IOW,如果 A 和 B 互相导入,但其中一个不使用另一个的符号,编译器可能会让它通过。一旦开始使用符号(因为通过选择操作可以访问之前无效的代码),它就会变成相互引用冲突。

If you are absolutely sure that you compile the right source (.dpr paths!) and the uses parts are the same, it might be that Delphi can eliminate mutual references if very simple or unused.

IOW maybe the compiler lets it pass if A and B import eachother, but one of them doesn't use symbols from the other. As soon as you start using symbols (because of previously dead code becoming reachable by selecting the action), it turns into a mutual reference conflict.

紫南 2024-09-19 06:48:04

有时添加组件会自动更改使用子句。这可以由 Delphi 本身完成,也可以由 ModelMaker CodeExplorer 等第三方插件完成。您可以使用历史记录选项卡快速识别任何更改。

没有源就没有更多的说法我可以...

编辑:考虑到您的附加信息,我建议检查项目

  1. 循环依赖
  2. 中搜索路径中某处具有相同名称的

项单元对于您的循环依赖项可以使用 ModelMakerTools 提供的免费单元依赖性分析器。您可以在该页面底部找到下载链接。

Sometimes adding a component automatically changes the uses clause. This can either be done by Delphi itself or by a third-party plugin like ModelMaker CodeExplorer. You can use the history tab to quickly identify any changes.

Without the source nothing more say I can...

EDIT: Taken into account your additional info I suggest to check the project for

  1. cyclic dependencies
  2. units with the same name somewhere in the search path

For the cyclic dependencies you can use the free Unit Dependency Analyzer from ModelMakerTools. You can find the download link at the bottom of that page.

孤城病女 2024-09-19 06:48:04

根据要求我的评论作为答案。

不知道为什么会发生这种情况,但如果有什么安慰的话,我也看到它在其他情况下发生。更改后立即构建将失败,编译,然后构建将成功。

有时在这些情况下也有帮助的是在编译/构建之前显式保存全部。

我猜这可能与IDE中的计时和缓存有关。可能还涉及启用代码洞察、错误红线等的编译线程。

As per request my comment as an answer.

Don't know why it may be happening, but if its any consolation, I have seen it happen in other situations as well. A build immediately following a change would fail, a compile, then a build would succeed.

What sometimes also helps in these situations is an explicit Save All before the compile/build.

I guess it may have something to do with timing and caching in the IDE. Possibly the compilation thread(s) that enable code-insight, error red lining etc are involved as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文