I am using Delphi XE IDE. I create a notifier to implement IOTACompileNotifier. After install the expert in the IDE. The code works fine when I compile my project. The notifier is working for ProjectCompileStarted.
The second time I compile my project, the Delphi IDE prompt:
[Fatal Error] Access violation at address 21B7FBED in module 'delphicoreide150.bpl'. Read of address 00000000
Although it seems weird that I perform:
var i: integer;
begin
i := Project.ProjectBuilder.AddCompileNotifier(TProjectCompileNotifier.Create);
Project.ProjectBuilder.RemoveCompileNotifier(i);
end;
in notifier. I just want to show Add and Remove compile notifier for ProjectBuilder seems not functioning properly no matter how I use.
Please advise how should I implement IOTAProjectCompileNotifier.
Thank you.
Here are the full source code:
type
TProjectCompileNotifier = class(TInterfacedObject, IOTAProjectCompileNotifier)
protected
procedure AfterCompile(var CompileInfo: TOTAProjectCompileInfo);
procedure BeforeCompile(var CompileInfo: TOTAProjectCompileInfo);
procedure Destroyed;
end;
TCompileNotifier = class(TInterfacedObject, IOTACompileNotifier)
protected
procedure ProjectCompileStarted(const Project: IOTAProject; Mode: TOTACompileMode);
procedure ProjectCompileFinished(const Project: IOTAProject; Result: TOTACompileResult);
procedure ProjectGroupCompileStarted(Mode: TOTACompileMode);
procedure ProjectGroupCompileFinished(Result: TOTACompileResult);
end;
procedure TCompileNotifier.ProjectCompileStarted(const Project: IOTAProject;
Mode: TOTACompileMode);
var i: integer;
begin
i := Project.ProjectBuilder.AddCompileNotifier(TProjectCompileNotifier.Create);
Project.ProjectBuilder.RemoveCompileNotifier(i);
end;
var i: integer;
initialization
i := (BorlandIDEServices as IOTACompileServices).AddNotifier(TCompileNotifier.Create);
finalization
(BorlandIDEServices as IOTACompileServices).RemoveNotifier(i);
end.