我们的 Delphi 7 开发团队以文本模式存储表单文件 (dfm),并使用源代码控制系统 (Subversion) 来跟踪更改。
有时,我们注意到一个表单文件在修订之间返回二进制格式,导致像 TortoiseMerge 这样的差异工具抱怨。
使用 Subversion 更改日志,我可以看到 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 中自行打开而它所属的项目没有打开时。
当 IDE 感到困惑时,有时会发生这种情况。
它通常在您在 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 打开项目(或更改了默认设置),他可能会以不同的格式保存表单。
您可能有兴趣研究 Beyond Compare 的使用,而不是 TortoiseSVN 的内置合并工具。Beyond Compare 是用 Delphi 编写的,并且本机知道如何读取二进制 DFM。这意味着无论您的 DFM 是以二进制还是文本形式存储在 Subversion 中,这都不再是一个问题(甚至没有问题)。Beyond Compare V3 还进行 3 路合并,这使得合并多个提交等变得非常容易。即使忽略区分二进制 DFM 的能力,它仍然是比 TortoiseSVN 的内置工具更好的差异查看器。我强烈推荐它,而且它非常便宜(我与 Scooter Software 没有任何关系,除了是一个非常满意的客户)。
我们当然遇到过这种情况。我们专门使用 D7。
从来没有深入了解它,因为它每年只发生六次左右,虽然它很麻烦,但很容易补救。
我很想看看 Lars 的回答,并且肯定会在下次发生这种情况时看看这是否是可能的原因。
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).