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 n
I think I might be able to answer this. I don't have XE and so I don't appear to have IOTAProjectCompileNotifier
. However, the other AddNotifier
methods in my ToolsAPI unit suggest it will be declared as:
function AddNotifier(const ANotifier: IOTAProjectCompileNotifier): Integer;
You call this routine this way:
i := Project.ProjectBuilder.AddCompileNotifier(TProjectCompileNotifier.Create);
The problem is that nothing takes a reference to the interface returned by TProjectCompileNotifier.Create
. You need to do so, like this:
procedure TCompileNotifier.ProjectCompileStarted(const Project: IOTAProject; Mode: TOTACompileMode);
var
i: integer;
Intf: IOTAProjectCompileNotifier;
begin
Intf := TProjectCompileNotifier.Create;
i := Project.ProjectBuilder.AddCompileNotifier(Intf);
Project.ProjectBuilder.RemoveCompileNotifier(i);
end;
You'd need to do likewise in the initialization/finalization code.
I believe that this really should be considered a bug in the interface reference counting implementation. It has been discussed here on Stack Overflow many times.