GExpert's Replace Components Expert doesn't replace the text in the form file (*.dfm)

北城余情 提交于 2019-12-06 13:19:44

You might be running into this bug while trying to copy the Touch property from the old to the new component, but it has a workaround you can fairly easily test: http://tech.groups.yahoo.com/group/GExpertsDiscuss/message/3994

Details:

There is a limitation/bug in Delphi 2010 and XE where if you assign a Component.Touch property from one component to another and destroy the original component that the new component becomes corrupt (it isn't like component/interface references, where they either auto-correct themselves or are reference counted).

For the moment, you can assign a bi-directional replace component property map from TPanel.Touch to TGroupBox.Touch (use the two components being replaced in your specific case) that is marked as a disabled property map, and that will work around this problem. Our next release will not try to assign that property any longer.

GExperts 1.36 is also now available and includes a workaround for this issue. The workaround has been in the GExperts version control system and in testing for several weeks already.

I just tried it with Delphi XE and GExperts 1.35 and it does indeed crash now even after a single "Replace Selected". (It used to work fine in the past).

It seems that using the hidden menu Project | Clear Unit Cache just after Replace Components then doing a full build before trying any Save/Compile/View As Text... fixes the problem.

I think this menu is surfaced with cnPack. I don't have it and cannot guarantee, but you can easily do it yourself by adding the following unit in one of your installed packages:

unit FGEnableHiddenMenus;

interface

procedure Register;

implementation

uses
  Classes, Forms, Menus;

procedure Register;
var
  Comp: TComponent;
begin
  //Make a hidden menu item visible
  Comp := Application.MainForm.FindComponent('ProjectClearUnitCacheItem');
  if Comp is TMenuItem then
    TMenuItem(Comp).Visible := True;
end;

end.

Source: Brian Long's old goodies

Update: I had to replace a couple of TEdit by TDBEdit on our main project at work and this trick worked.
But on a new Project with 3 Forms, it failed consistently to write/commit/save the changes on the last Form (same environment).
FYI, I tried with and without DDevExtensions 2.5 and IDEFixPack 4.6.1

Update2: Went digging in the GExperts forum as suggested by Ulrich and finally found a possible explanation. The new property Touch does not like being copied from one component to another when the source is destroyed (causing the AV).
The suggested workaround is to do a bidirectional mapping in the Expert Settings to disable the copy for this property:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!