浏览代码

* Patch from Martin Schreiber to fix streaming inherited collections
(mantis #11774)

git-svn-id: trunk@11679 -

michael 17 年之前
父节点
当前提交
d0d3a79731
共有 2 个文件被更改,包括 7 次插入3 次删除
  1. 6 2
      rtl/objpas/classes/classes.inc
  2. 1 1
      rtl/objpas/classes/writer.inc

+ 6 - 2
rtl/objpas/classes/classes.inc

@@ -772,14 +772,18 @@ function CollectionsEqual(C1, C2: TCollection; Owner1, Owner2: TComponent): Bool
     if (c1.classtype<>c2.classtype) or
       (c1.count<>c2.count) then
       exit;
-
+    if c1.count = 0 then
+      begin
+      result:= true;
+      exit;
+      end;
     s1:=tmemorystream.create;
     try
       s2:=tmemorystream.create;
       try
         stream_collection(s1,c1,owner1);
         stream_collection(s2,c2,owner2);
-        result:=(s1.size=s2.size) and (CompareChar(s1.memory,s2.memory,s1.size)=0);
+        result:=(s1.size=s2.size) and (CompareChar(s1.memory^,s2.memory^,s1.size)=0);
       finally
         s2.free;
       end;

+ 1 - 1
rtl/objpas/classes/writer.inc

@@ -938,7 +938,7 @@ begin
           else if ObjValue.InheritsFrom(TCollection) then
             begin
             if (not HasAncestor) or (not CollectionsEqual(TCollection(ObjValue),
-              TCollection(GetObjectProp(Ancestor, PropInfo)))) then
+              TCollection(GetObjectProp(Ancestor, PropInfo)),root,rootancestor)) then
               begin
               Driver.BeginProperty(FPropPath + PPropInfo(PropInfo)^.Name);
               SavedPropPath := FPropPath;