浏览代码

* Applied bugfix by Mattias Gaertner for TWriter.WriteProperty
(writing of NIL object instanced caused an invalid access)
* Optimized some 'is'/InheritsFrom occurencies

sg 25 年之前
父节点
当前提交
95e54154e1
共有 1 个文件被更改,包括 15 次插入8 次删除
  1. 15 8
      fcl/inc/writer.inc

+ 15 - 8
fcl/inc/writer.inc

@@ -467,7 +467,7 @@ begin
     if not IgnoreChildren then
     if not IgnoreChildren then
       try
       try
         // Set up the ancestor list if we have an ancestor
         // Set up the ancestor list if we have an ancestor
-        if Assigned(FAncestor) and FAncestor.InheritsFrom(TComponent) then
+        if FAncestor is TComponent then
         begin
         begin
           if csInline in TComponent(FAncestor).ComponentState then
           if csInline in TComponent(FAncestor).ComponentState then
             FRootAncestor := TComponent(FAncestor);
             FRootAncestor := TComponent(FAncestor);
@@ -708,13 +708,15 @@ begin
 	end else
 	end else
           AncestorObj := nil;
           AncestorObj := nil;
 
 
-	if (not Assigned(ObjValue)) and (ObjValue <> AncestorObj) then
+	if not Assigned(ObjValue) then
 	begin
 	begin
-          Driver.BeginProperty(FPropPath + PPropInfo(PropInfo)^.Name);
-	  Driver.WriteIdent('NIL');
-	  Driver.EndProperty;
-	end else If Assigned(ObjValue) then
-	if ObjValue.InheritsFrom(TPersistent) then
+	  if ObjValue <> AncestorObj then
+	  begin
+	    Driver.BeginProperty(FPropPath + PPropInfo(PropInfo)^.Name);
+	    Driver.WriteIdent('NIL');
+	    Driver.EndProperty;
+	  end;
+	end else if ObjValue.InheritsFrom(TPersistent) then
           if ObjValue.InheritsFrom(TComponent) then
           if ObjValue.InheritsFrom(TComponent) then
              begin
              begin
              Component := TComponent(ObjValue);
              Component := TComponent(ObjValue);
@@ -805,7 +807,12 @@ end;}
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.1.2.1  2000-12-10 14:32:08  michael
+  Revision 1.1.2.2  2000-12-20 23:14:18  sg
+  * Applied bugfix by Mattias Gaertner for TWriter.WriteProperty
+    (writing of NIL object instanced caused an invalid access)
+  * Optimized some 'is'/InheritsFrom occurencies
+
+  Revision 1.1.2.1  2000/12/10 14:32:08  michael
   + Added check for Object<>nil in streamer
   + Added check for Object<>nil in streamer
 
 
   Revision 1.1  2000/07/13 06:31:32  michael
   Revision 1.1  2000/07/13 06:31:32  michael