fix: program stuck after display change

This commit is contained in:
Massimo Melina 2020-05-15 11:47:41 +02:00
parent c77912c94e
commit 12c3804dcf

View File

@ -2591,10 +2591,25 @@ try
except end; except end;
end; // setDynamicComment 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; function Tfile.getParent():Tfile;
begin begin
if node = NIL then result:=NIL if node = NIL then
else if isTemp() then result:=nodeToFile(node) 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 if node.parent = NIL then result:=NIL
else result:=node.parent.data else result:=node.parent.data
end; // getParent end; // getParent
@ -3043,7 +3058,7 @@ end; // recursiveApply
function Tfile.hasRecursive(attributes: TfileAttributes; orInsteadOfAnd:boolean=FALSE; outInherited:Pboolean=NIL):boolean; function Tfile.hasRecursive(attributes: TfileAttributes; orInsteadOfAnd:boolean=FALSE; outInherited:Pboolean=NIL):boolean;
var var
f, p: Tfile; f: Tfile;
begin begin
result:=FALSE; result:=FALSE;
f:=self; f:=self;
@ -3053,10 +3068,7 @@ while assigned(f) do
result:=orInsteadOfAnd and (attributes*f.flags <> []) result:=orInsteadOfAnd and (attributes*f.flags <> [])
or (attributes*f.flags = attributes); or (attributes*f.flags = attributes);
if result then exit; if result then exit;
p:=f.parent; f:=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;
if assigned(outInherited) then outInherited^:=TRUE; if assigned(outInherited) then outInherited^:=TRUE;
end; end;
if assigned(outInherited) then outInherited^:=FALSE; // grant it is set only if result=TRUE if assigned(outInherited) then outInherited^:=FALSE; // grant it is set only if result=TRUE
@ -5418,9 +5430,9 @@ var
exit; exit;
end; end;
if urlCmd = '~login' then if urlCmd = '~login' then // legacy method for login dialog
if conn.request.user = '' then if conn.request.user = '' then
begin // issue a login dialog begin
getPage('unauthorized', data); getPage('unauthorized', data);
if loginRealm > '' then if loginRealm > '' then
conn.reply.realm:=loginRealm; conn.reply.realm:=loginRealm;