Browse Source

* Handle OwnsObjects when doing revert on self

Michaël Van Canneyt 3 weeks ago
parent
commit
c8813fcb20
1 changed files with 9 additions and 0 deletions
  1. 9 0
      rtl/objpas/classes/stringl.inc

+ 9 - 0
rtl/objpas/classes/stringl.inc

@@ -424,17 +424,26 @@ Procedure TStrings.Reverse(aList : TStrings);
 Var
   I : Integer;
   lList : TStrings;
+  lOwns : boolean;
 
 begin
+  lOwns:=False;
   if aList=self then
     begin
     lList:=Nil;
     BeginUpdate;
     try
+      if (self is TStringList) then
+        begin
+        lOwns:=TstringList(Self).OwnsObjects;
+        TStringList(Self).OwnsObjects:=False;
+        end;
       lList:=TStringList.Create;
       Reverse(lList);
       AddStrings(lList,True);
     finally
+      if (self is TStringList) then
+        TStringList(Self).OwnsObjects:=lOwns;
       EndUpdate;
       lList.Free;
     end;