kooloveme / thtmlviewer

Automatically exported from code.google.com/p/thtmlviewer
Other
0 stars 0 forks source link

Double call of OnInclude event #349

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Which steps will reproduce the problem?
1. Set a breakpoint in TForm1.FrameViewerInclude of FDemUnit, project FrameDem

Why this happens?
The OnInclude event of TFrameViewer is being called two times by each parse. 
I’m not sure if this is by design or an undesired effect (in my case the last 
is true).

This happens because THtmlParser.ParseHtml assigns IncludeEvent:= AIncludeEvent 
before Max Tab loop finished (line 4180 of version 11.4)

Just moving this line (IncludeEvent:= AIncludeEvent) after the count loop 
(namely line 4429), will avoid this behavior.

-----------------------------------------
I take this opportunity to thank HTMLViewer Team for have updated this code. 
They have done a fantastic job. In 2007 I used THTML to develop SpidEye  a free 
web browser.
-----------------------------------------

Original issue reported on code.google.com by miguelGa...@gmail.com on 26 Apr 2014 at 6:39

GoogleCodeExporter commented 9 years ago
Hi Miguel,

I'm glad that you like HtmlViwer :)

It is intended, that the event is fired as well while counting tabs, as the 
parser otherwise cannot see included links.

But it seems that the only action in the Max Tab loop actually is counting the 
links to avoid creating too many tab controls for too many links. Most 
documents do not reached this number and in case there are too many links the 
previously created controls could be freed again. This way the Max Tab loop is 
not needed and your problem solved. 

OrphanCat

Original comment by OrphanCat on 27 Apr 2014 at 1:39

GoogleCodeExporter commented 9 years ago
Thanks OrphanCat, 

The logic of my program needs to know which time the InlcudeEvent is called 
(for counting tabs or for actually returning text). 

It will be nice to have a status indicating this, something like a property: 
ContingTabs:= true, for example.

However, that is ok, I will fix my local copy.

Thank you for you time.

Miguel

Original comment by miguelGa...@gmail.com on 3 May 2014 at 10:15