瀏覽代碼

* Handle OwnsObjects when doing revert on self

Michaël Van Canneyt 3 周之前
父節點
當前提交
c8813fcb20
共有 1 個文件被更改,包括 9 次插入0 次删除
  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
 Var
   I : Integer;
   I : Integer;
   lList : TStrings;
   lList : TStrings;
+  lOwns : boolean;
 
 
 begin
 begin
+  lOwns:=False;
   if aList=self then
   if aList=self then
     begin
     begin
     lList:=Nil;
     lList:=Nil;
     BeginUpdate;
     BeginUpdate;
     try
     try
+      if (self is TStringList) then
+        begin
+        lOwns:=TstringList(Self).OwnsObjects;
+        TStringList(Self).OwnsObjects:=False;
+        end;
       lList:=TStringList.Create;
       lList:=TStringList.Create;
       Reverse(lList);
       Reverse(lList);
       AddStrings(lList,True);
       AddStrings(lList,True);
     finally
     finally
+      if (self is TStringList) then
+        TStringList(Self).OwnsObjects:=lOwns;
       EndUpdate;
       EndUpdate;
       lList.Free;
       lList.Free;
     end;
     end;