Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TWebBrowser bug?


This question is answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Jul 30, 2016 6:36 AM Last Post By: Brian Wheatley
Brian Wheatley

Posts: 60
Registered: 2/5/01
TWebBrowser bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 29, 2016 11:30 AM
I have a FireMonkey application with a TMenuBar and a TWebBrowser on the main form. When the form is shown I have the TWebBrowser navigate to a specific page. What is odd is that if I open one of the sub-menus on the menu bar the TWebBrowser flashes then reloads the web page. Then when I exit the application the program crashes at this method of FMX.WebBrowser:

procedure TCustomWebBrowser.FormHandleDestroyed(const Sender: TObject; const Msg: TMessage);
var
  WBService : IFMXWBService;
begin
  if not (csDesigning in ComponentState) and TPlatformServices.Current.SupportsPlatformService(IFMXWBService, WBService) then
  begin
    FURL := FWeb.URL;                   <= FWeb is nil causing an access violation
    WBService.DestroyWebBrowser(FWeb);
    FWeb := nil;
  end;
end;


Even without event handlers on the menu items, as soon as a sub-menu pops up the browser refreshes itself.

I tried replacing the TMenuBar with a TMenu and get the same result.

Is this a bug? Is there a work around?

Edited by: Brian Wheatley on Jul 29, 2016 11:32 AM

Eli M

Posts: 1,346
Registered: 11/9/13
Re: TWebBrowser bug?
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 30, 2016 5:13 AM   in response to: Brian Wheatley in response to: Brian Wheatley
Yes, bug.

https://quality.embarcadero.com/browse/RSP-15559

"My work-around is to use a local copy of FMX.WebBrowser.pas and in the procedure TCustomWebBrowser.FormHandleDestroyed(const Sender: TObject; const Msg: TMessage); method explicitly check is Owner is the same as Sender, because that will/should indicate whether the TWebBrowser is really affected or not."

https://quality.embarcadero.com/browse/RSP-14724

"My fix for this in a Windows app is just to free the web browser in MyMainForm.OnClose. I am using TTMSFMXWebOSMaps which uses TWebBrowser and it throws this AV. If you add MyTMSFMXWebOSMaps.Free; to MyMainForm.OnClose the AV doesn't happen."

"I don't know if this is the best solution, but my fix was to add lines to the beginning of FormHandleCreated and FormHandleDestroyed, something like:
if Self.Root.GetObject <> Sender then // Don't do anything unless it is the form that owns the web browser object that is being destroyed.
Exit;"
Brian Wheatley

Posts: 60
Registered: 2/5/01
Re: TWebBrowser bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 30, 2016 6:36 AM   in response to: Eli M in response to: Eli M
Thank you! Thank you!!
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02