El 30/09/16 a les 12:46, Mattias Gaertner via Lazarus ha escrit:
On Fri, 30 Sep 2016 12:27:46 +0200
Luca Olivetti via Lazarus <lazarus@lists.lazarus-ide.org> wrote:
[...]
FWIW, "transplanting" the version of turbopower_ipro from lazarus 1.4.4
to 1.6 (and defining html_print in its lpk otherwise it doesn't compile)
"solves" this problem.
I now found that the problem is with the directive
{$MODESWITCH NESTEDPROCVARS}.
If I compile the old turbopower_ipro with this directive (even if it
doesn't need it) it doesn't work (the information box doesn't show
anything, though I didn't manage to crash lazarus yet), while if I
rewrite the new iphtml.pas in order to remove the directive it works OK.
Does that mean you will provide a patch to fix this?
Yes, attached (beware, made under windows with TortoiseSVN), but it's
less "elegant" that the solution with nestedprocvars (if it is supposed
to work).
And, as I said to Ondrej, there are more units using that switch.
A bug in fpc 2.6.4?
Maybe. Although it exists since 2.6.0.
I could file a bug then but I'm afraid I cannot produce a simple test case.
Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007
Index: ipdefine.inc
===================================================================
--- ipdefine.inc (revision 53057)
+++ ipdefine.inc (working copy)
@@ -47,7 +47,7 @@
{$DEFINE VERSION5}
{$DEFINE Version6OrHigher}
{$DEFINE Version7OrHigher}
-{$MODESWITCH NESTEDPROCVARS}
+//{$ MODESWITCH NESTEDPROCVARS}
{$ELSE}
Index: iphtml.pas
===================================================================
--- iphtml.pas (revision 53057)
+++ iphtml.pas (working copy)
@@ -2710,7 +2710,7 @@
property FlagErrors;
end;
- TIdFindNodeCriteria = function(ACurrNode: TIpHtmlNodeCore): Boolean is nested;
+ TIdFindNodeCriteria = function(ACurrNode: TIpHtmlNodeCore; const AId:string): Boolean;
const
NAnchorChar = #3 ; {character used to represent an Anchor }
@@ -2739,7 +2739,7 @@
function GetNextSiblingNode(ANode: TIpHtmlNode): TIpHtmlNode;
function GetPrevSiblingNode(ANode: TIpHtmlNode): TIpHtmlNode;
function GetParentNodeOfClass(ANode: TIpHtmlNode; AClass: TIpHtmlNodeClass): TIpHtmlNode;
-function FindNode(ANode: TIpHtmlNode; ACriteria: TIdFindNodeCriteria): TIpHtmlNodeCore;
+function FindNode(ANode: TIpHtmlNode; ACriteria: TIdFindNodeCriteria; const AId:string): TIpHtmlNodeCore;
function FindNodeByElemId(ANode: TIpHtmlNode; const AElemId: string): TIpHtmlNodeCore;
function FindNodeByElemClass(ANode: TIpHtmlNode; const AElemClass: string): TIpHtmlNodeCore;
@@ -2935,7 +2935,7 @@
Result := Result.FParentNode;
end;
-function FindNode(ANode: TIpHtmlNode; ACriteria: TIdFindNodeCriteria): TIpHtmlNodeCore;
+function FindNode(ANode: TIpHtmlNode; ACriteria: TIdFindNodeCriteria; const AId:string): TIpHtmlNodeCore;
var
I: Integer;
VNode: TIpHtmlNodeMulti;
@@ -2949,43 +2949,41 @@
for I := 0 to Pred(VNode.ChildCount) do
begin
VPrevNode := VNode.ChildNode[I];
- VNextNode := FindNode(VPrevNode, ACriteria);
+ VNextNode := FindNode(VPrevNode, ACriteria, AId);
if not Assigned(VNextNode) then
VNextNode := VPrevNode;
if VNextNode is TIpHtmlNodeCore then
begin
Result := VNextNode as TIpHtmlNodeCore;
- if ACriteria(Result) then
+ if ACriteria(Result,AId) then
Exit;
end;
end;
Result := nil;
end;
+function CriteriaByElemId(ACurrNode: TIpHtmlNodeCore; const AElemId:string): Boolean;
+begin
+ if ACurrNode.Id = AElemId then
+ Exit(True);
+ Result := False;
+end;
+
function FindNodeByElemId(ANode: TIpHtmlNode; const AElemId: string): TIpHtmlNodeCore;
+begin
+ Result := FindNode(ANode, CriteriaByElemId, AElemId);
+end;
- function Criteria(ACurrNode: TIpHtmlNodeCore): Boolean;
- begin
- if ACurrNode.Id = AElemId then
- Exit(True);
- Result := False;
- end;
-
+function CriteriaByElementClass(ACurrNode: TIpHtmlNodeCore; const AElemClass:string): Boolean;
begin
- Result := FindNode(ANode, Criteria);
+ if ACurrNode.ClassId = AElemClass then
+ Exit(True);
+ Result := False;
end;
function FindNodeByElemClass(ANode: TIpHtmlNode; const AElemClass: string): TIpHtmlNodeCore;
-
- function Criteria(ACurrNode: TIpHtmlNodeCore): Boolean;
- begin
- if ACurrNode.ClassId = AElemClass then
- Exit(True);
- Result := False;
- end;
-
begin
- Result := FindNode(ANode, Criteria);
+ Result := FindNode(ANode, CriteriaByElementClass, AElemClass);
end;
procedure Register;
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus