IDE. A class named already exists.

Error registering component in TMS IDE.

I have huge application which, registers most of the classes on start. And when I try to register components within TMS IDE Engine, I keep getting errors, and none of the components are registered.

Example of Error message:
---------------------------
Debugger Exception Notification
---------------------------
Project Ololo40.exe raised exception class EFilerError with message 'A class named TDBGrid already exists'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help   
---------------------------

Call stack:
TRegGroup.RegisterClass(TDBGrid)
TRegGroups.RegisterClass(TDBGrid)
RegisterClass(TDBGrid)
TIDERegisteredComp.SetCompClass(TDBGrid)
TIDEEngine.RegisterComponent('Data Controls',TDBGrid,'Grids,DBGrids')
IDERegisterDataControlsTab($3D8EC80)


The problem is in unit IDEMain.pas in procedure SetCompClass of TIDERegisteredComp

procedure TIDERegisteredComp.SetCompClass(const Value: TComponentClass);
begin
  FCompClass := Value;
  RegisterClass(FCompClass);
end;              


I suggest you to add check if class hasn't been already registered before call RegisterClass. Here's fixed code:

procedure TIDERegisteredComp.SetCompClass(const Value: TComponentClass);
begin
  FCompClass := Value;
  if GetClass(Value.ClassName)=nil then
    RegisterClass(FCompClass);
end;

Duplicated support request, I have answered your question from e-mail. I can't reproduce the problem here, we can follow up through e-mail.

Wagner, I got your mail. I researched my code, and defined why this error appears. I got error, because I replaced DbGrids.TDbGrid type with my own, custom-defined class.


Here is example code:

procedure TForm5.btnTempClick(Sender: TObject);
begin
  IDEEngine1.RegisterComponent('Bla', TDBGrid); // error will be here
  IDEEngine1.RegisterComponent('Bla', TDBGrid);
end;

type
  TDbGrid = class(TButton) // instead of TButton I use my own grid with enhanced capabilities
  end;

initialization
  RegisterClass(TDBGrid);
end.

p.s. now I realise that it's my own bug.