Hallo I get sometimes Exceptions (Programm terminates) after TChromium.Destroy
Reason: TCustomClientHandler fires Events to destoyed TChromium
I fixed it by:
TCustomClientHandler = class(TCefClientOwn)
public ...
procedure DisconnectEvents;
destructor TCustomClientHandler.Destroy;
begin
DisconnectEvents;
inherited Destroy;
end;
procedure TCustomClientHandler.DisconnectEvents;
begin
FLoadHandler := nil;
FFocusHandler := nil;
FContextMenuHandler := nil;
FDialogHandler := nil;
FKeyboardHandler := nil;
FDisplayHandler := nil;
FDownloadHandler := nil;
FGeolocationHandler := nil;
FJsDialogHandler := nil;
FLifeSpanHandler := nil;
FRequestHandler := nil;
FRenderHandler := nil;
FDragHandler := nil;
FFindHandler := nil;
FEvents := nil;
end;
destructor TChromium.Destroy;
begin ...
if assigned(FHandler) then
TVCLClientHandler(FHandler).DisconnectEvents;
FHandler := nil;
Is there a better way to resolve this?
Kindly regards
Andreas Michelberger
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Programm terminates after TChromium.Destroy
-
- Posts: 12
- Joined: Tue Aug 08, 2017 11:42 am
- salvadordf
- Posts: 4049
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Programm terminates after TChromium.Destroy
That was caused by a recent change in CEF's destruction sequence.
I created this issue about it :
https://github.com/salvadordf/CEF4Delphi/issues/53
The ToolboxBrowser and MDIBrowser demos included the fix for that.
As you can see in those demos, you have to remove the manual destruction of the TChromium component from TChildForm.BrowserDestroyMsg
You should only destroy TCEFWindowParent manually in that event and let the other components be destroyed when the form is destroyed.
I created this issue about it :
https://github.com/salvadordf/CEF4Delphi/issues/53
The ToolboxBrowser and MDIBrowser demos included the fix for that.
As you can see in those demos, you have to remove the manual destruction of the TChromium component from TChildForm.BrowserDestroyMsg
You should only destroy TCEFWindowParent manually in that event and let the other components be destroyed when the form is destroyed.