Browse Source

* extract a symbol or def from its previous owner if that owner has OwnsObjects set to true

Sven/Sarah Barth 3 years ago
parent
commit
a7a0f47d98
1 changed files with 4 additions and 2 deletions
  1. 4 2
      compiler/symtype.pas

+ 4 - 2
compiler/symtype.pas

@@ -510,8 +510,8 @@ implementation
 
     procedure tdef.ChangeOwner(st:TSymtable);
       begin
-//        if assigned(Owner) then
-//          Owner.DefList.List[i]:=nil;
+        if assigned(Owner) and owner.deflist.OwnsObjects then
+          Owner.DefList.extract(self);
         Owner:=st;
         Owner.DefList.Add(self);
       end;
@@ -680,6 +680,8 @@ implementation
 
     procedure tsym.ChangeOwner(st:TSymtable);
       begin
+        if assigned(owner) and owner.SymList.OwnsObjects then
+          owner.symlist.extract(self);
         Owner:=st;
         inherited ChangeOwner(Owner.SymList);
       end;