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
error code "Read of address 00000000" can indicate that you are trying to access a resource which does not exist. I saw that you've asked the same question on the Embarcadero forum. From what I saw on here on SO, there are only several developers who are interested on OTA, the documentation from CG or Embarcadero is almost inexistent, so I'm suggesting you to insist on Embarcadero's forum.
best regards,
Radu
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.
I wonder why you're removing your notifier from within the callback. I could imagine that scenario is not handled well by OTA. Try the following: first (when the package is loaded and initialized) install an IOTAIDENotifier to be notified when a project is open (remove it in finalization). Implement its FileNotification to add your IOTAProjectCompileNotifier when a project is open, remove it when it's closed.