From 12c3804dcf577318e4fc944cc50540077c5e621f Mon Sep 17 00:00:00 2001 From: Massimo Melina Date: Fri, 15 May 2020 11:47:41 +0200 Subject: [PATCH] fix: program stuck after display change --- main.pas | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/main.pas b/main.pas index 5c78e3d..b056432 100644 --- a/main.pas +++ b/main.pas @@ -2591,10 +2591,25 @@ try except end; end; // setDynamicComment +procedure fixTreeStructure(n: TTreeNode); +var + i: integer; +begin +Tfile(n.data).node:=n; +for i:=0 to n.count-1 do + fixTreeStructure(n.Item[i]) +end; // fixTreeStructure + function Tfile.getParent():Tfile; begin -if node = NIL then result:=NIL -else if isTemp() then result:=nodeToFile(node) +if node = NIL then + begin + result:=NIL; + exit; + end; +if node.data <> self then // the tree structure is unreliable, at least on DISPLAYCHANGE event. This will workaround it + fixTreeStructure(mainFrm.filesBox.Items[0]); +if isTemp() then result:=nodeToFile(node) else if node.parent = NIL then result:=NIL else result:=node.parent.data end; // getParent @@ -3043,7 +3058,7 @@ end; // recursiveApply function Tfile.hasRecursive(attributes: TfileAttributes; orInsteadOfAnd:boolean=FALSE; outInherited:Pboolean=NIL):boolean; var - f, p: Tfile; + f: Tfile; begin result:=FALSE; f:=self; @@ -3053,10 +3068,7 @@ while assigned(f) do result:=orInsteadOfAnd and (attributes*f.flags <> []) or (attributes*f.flags = attributes); if result then exit; - p:=f.parent; - if f = p then // i noticed some hangs lately, possibly an infinite loop here. Trying to debug it - raise Exception.Create('invalid hierarchy '+f.name); - f:=p; + f:=f.parent; if assigned(outInherited) then outInherited^:=TRUE; end; if assigned(outInherited) then outInherited^:=FALSE; // grant it is set only if result=TRUE @@ -5418,9 +5430,9 @@ var exit; end; - if urlCmd = '~login' then + if urlCmd = '~login' then // legacy method for login dialog if conn.request.user = '' then - begin // issue a login dialog + begin getPage('unauthorized', data); if loginRealm > '' then conn.reply.realm:=loginRealm;