Delphi 有时会将文本表单文件 (DFM) 恢复为二进制格式吗?
我们的 Delphi 7 开发团队以文本模式存储表单文件 (dfm),并使用源代码控制系统 (Subversion) 来跟踪更改。
有时,我们注意到表单文件在修订之间返回为二进制格式,导致 TortoiseMerge 等 diff 工具抱怨。
使用Subversion更改日志,我可以看到DFM文件之前是以文本形式存储的。 软件开发人员从不手动将存储文件格式更改回二进制。
你也遇到过同样的情况吗? 这是一个已知问题吗?
Our Delphi 7 development team stores form files (dfm) in text mode, and uses a source control system (Subversion) to track changes.
Sometimes, we noticed that a form file returned to binary format between revisions, causing diff tools like TortoiseMerge to complain.
Using the Subversion change log, I can see that the DFM file was stored in text form before. The software developers never change the storage file format back to binary manually.
Have you encountered the same? Is it a known problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
这确实发生在 Delphi 7 中,但在更高版本中得到修复。 通常,您可以通过打开 .pas 文件然后切换到表单视图来访问 IDE 中的表单。 右键单击您的表单,如果您以前这样做过,它会显示“Text DFM”已勾选。
当您在 Delphi 7 IDE 中直接打开 .dfm 文件时,您将遇到您所描述的文本 DFM 切换到二进制 DFM 的问题。 例如。 文件->打开->Somefile.dfm ..右键单击 dfm 并选择“以表单查看”。 现在右键单击该表单,您将看到“Text DFM”未被选中。
当我们打开 DFM(grep 搜索结果)时,我们遇到了问题。 它也让我们感到困惑,并且会导致 cvs 中的 dfm 损坏,因为它是作为文本签入的。
This does happen in Delphi 7 but is fixed in later versions. Usually you access forms in the IDE by opening the .pas file and then switching to the Form View. Right click your form and it will show that it is "Text DFM" ticked if you have done this before.
You will experience the problem you have described of a text DFM switching to a binary DFM when in the Delphi 7 IDE you open the .dfm file directly. eg. File->Open->Somefile.dfm .. Right click the dfm and choose "View as Form". Now right click the form, you will see that the "Text DFM" is unticked.
We were getting the problem when we opened up a DFM which was a grep search result. It had us perplexed also, and would cause corruption of the dfm in cvs as it was checked in as text.
我在 Delphi 7 中看到过这种情况,当一个从不同项目的另一个表单继承的表单在 Delphi 中自行打开时,它所属的项目没有打开。
I have seen it happen in Delphi 7 when a form inheriting from another form from a different project was opened in Delphi on its own without the project it belongs to being open.
当 IDE 变得混乱时,有时会发生这种情况。
它通常在 Delphi 7 IDE 内发生访问冲突后启动。
有时,IDE 中的一个或多个 Delphi 编辑器缓冲区也会变成只读(而磁盘上的文件仍然是读/写的)。
这种行为发生的次数比 Delphi 5 或 6 中少得多,但有时在 Delphi 7 中确实会发生。
您能做的最好的事情就是在出现访问冲突时立即重新启动 Delphi 7 IDE。
This sometimes happens when the IDE gets confused.
It usually starts after you got an access violation inside the Delphi 7 IDE.
Sometimes also one or mor of your Delphi editor buffers inside the IDE become readonly (while the files on disk are still read/write).
The behaviour occurs much less than in Delphi 5 or 6, but sometimes it does occur in Delphi 7.
The best thing you can do is restart the Delphi 7 IDE as soon as you get an access violation.
如果有人用不同版本的Delphi打开项目(或更改了默认设置),他可能会以不同的格式保存表单。
If someone has opened the project with different version of Delphi (or changed the default settings), he may save the forms in different format.
您可能有兴趣研究如何使用 Beyond Compare 而不是 TortoiseSVN 的内置合并工具。 Beyond Compare 是用 Delphi 编写的,并且本身就知道如何读取二进制 DFM。 这意味着无论您的 DFM 以二进制还是文本形式存储在 Subversion 中,都不再是问题(甚至没有问题)。 Beyond Compare V3 还进行 3 路合并,这使得合并多个提交等变得非常容易。即使忽略比较二进制 DFM 的能力,它仍然是比 TortoiseSVN 的内置工具更好的比较查看器。 我强烈推荐它,而且它非常便宜(我与 Scooter Software 没有任何联系,除了是一个非常满意的客户)。
滑板车软件
You may be interested in investigating the use of Beyond Compare instead of TortoiseSVN's built-in merge tool. Beyond Compare is written in Delphi, and natively knows how to read binary DFMs. This means that it then becomes less of an issue (or even no issue) whether your DFMs are stored in Subversion in binary or text. Beyond Compare V3 also does 3-way merging which makes it really easy to merge multiple commits etc. Even ignoring the ability to diff binary DFMs, it's still a much better diff viewer than TortoiseSVN's built-in tools. I can highly recommend it, and it's very inexpensive (I have no connection with Scooter Software, other than being a very happy customer).
Scooter Software
我们肯定遇到过这种情况。 我们专门使用D7。
从来没有弄清楚它的真相,因为这种情况一年左右只发生六次,虽然这很麻烦,但很容易补救。
我对拉尔斯的回答很感兴趣,并且下次发生这种情况时肯定会看看这是否是可能的原因。
We've certainly encountered this. We use D7 exclusively.
Never got to the bottom of it as it happens only half a dozen times a year or so, and although it's a nuisance it's fairly easily remedied.
I was interested to see Lars's answer, and will certainly look to see if that's a possible cause next time it happens.
我们时不时也会遇到这个问题,它似乎与查看 DFM 的源代码(Alt-F12)然后执行 Visual Source Safe 操作(例如签入)有关。
We also have this issue from time to time, and it seems to be related to looking at the DFM's source (Alt-F12) and then doing a Visual Source Safe operation (e.g. check-in).