w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Interface DLL form app crashing

You never assign to Form_DLL. This means that when you call FreeF, you then perform FreeAndNil(Form_DLL). Since Form_DLL is nil, this does nothing, and the form still exists.

Fix that by changing LoadModule:

function LoadModule:IBaseModuleInterface;stdcall;
begin
  Assert(not Assigned(Form_DLL));
  Form_DLL:=TForm_DLL.Create(nil);
  result:=Form_DLL;
end;

Although, I'd probably change the design completely by removing Form_DLL altogether. The host app maintains a reference to the form, on which the call to Free can be made. In other words, remove Form_DLL and implement FreeF like this:

procedure TForm_DLL.FreeF;
begin
  Free; // or Destroy
end;

Or even better, use reference counted interfaces on the implementing object and let aModuleIntf:=nil take the form down.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.