Jump to content
chkaufmann

TEdgeBrowser - Problem on destroy

Recommended Posts

In my application I get this error:

exception class          : EAccessViolation
exception message        : Access violation at address 035CD729 in module 'Logo12.exe'. Read of address 00000000.

thread $343c:
035cd729 +0d Logo12.exe   Vcl.Edge   1679  +1 TCustomEdgeBrowser.ProcessHResult
035cc712 +52 Logo12.exe   Vcl.Edge   1028  +2 TCustomEdgeBrowser.CreateCoreWebView2ControllerCompleted
035d03e9 +11 Logo12.exe   Vcl.Edge    828  +1 {Vcl.Edge}Callback`2.CreateAs[3]$ActRec<System.HRESULT,Winapi.WebView2.ICoreWebView2Controller,Winapi.WebView2.ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>.$0$Body
75725c2b +0b user32.dll                       DispatchMessageW
006cb497 +f3 Logo12.exe   Vcl.Forms 11336 +23 TApplication.ProcessMessage
006cb4da +0a Logo12.exe   Vcl.Forms 11366  +1 TApplication.HandleMessage
006cb819 +d1 Logo12.exe   Vcl.Forms 11505 +27 TApplication.Run

 

Depending on the displayed data I create controls dynamically and for me this looks like my TEdgeBrowser control gets a message after it was already destroyed.

 

How can I ensure this doesn't happen? I tried to call Stop and the CloseBrowserProcess methods, but both don't work.

 

Christian

 

Share this post


Link to post

I could isolate the problem a bit more. Basically it happens when I try to destroy the TEdgeBrowser component during the time when the ICoreWebView2 object is in creation process. This runs async and the message when the setup has finished comes to late.

 

Now my quick and dirty solution before I destroy my TEdgebrowser is this:

  while (Browser.BrowserControlState = TCustomEdgeBrowser.TBrowserControlState.Creating)
    do Application.ProcessMessages;
  Browser.Free;

It works, but I don't like it since there are a lot of things that may happen in ProcessMessages.

 

I cannot post the whole code since this is an interaction between two components in an application at very different places. I try to describe it.

- I have two TVirtualTree controls, one to navigate the objects, the other to edit attributes.

- When the inplace editor for an URL is closed, I call Browser.Navigate with the new URL

- When the user changes to a different object (click in the tree for navigation), the Browser will be destroy because this object may not need a browser.

- Now the click in the object tree triggers an EndEdit in the edit tree (causes Browser.Navigate) in a moment when the object change process didn't start yet

 

I was thinking of creating a delayed Navigate method in the Browser using a special message so I post that message in the queue. So the Navigate will not happen before the object change click message has finished.

 

Regards
Christian

Share this post


Link to post

I don't know if I understood your proposal correctly!

  1. Does a VirtualTree start navigation?
  2. A VirtualTree is edit URL params (or any other info) for navigation?

If so, then you have a conflict of interest here!!!

Perhaps, it would be better for you to determine "exactly" when navigation starts. For example, using a boolean flag!

 

TVbrowser:
if ICanStartNavegation then
begin
   ICanStartNavegation := false; // again not, please!!!
   //
   BrowerXXXX.navegate(...);
end;

TVEdits:
if not ICanStartNavegation then
begin
  editXXX := zzzz; etc...
  //....
  ICanStartNavegation := true; //ok, you navegate now!
end;

 

  • Sad 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×