소스 검색

* TRegistry (XML flavor): check if FSysData is actually assigned in methods that are called from destructor. Destructor is executed when an exception occurs in constructor, but FSysData may not yet be assigned in this case.

git-svn-id: trunk@21293 -
sergei 13 년 전
부모
커밋
6e78f5217e
1개의 변경된 파일14개의 추가작업 그리고 5개의 파일을 삭제
  1. 14 5
      packages/fcl-registry/src/xregreg.inc

+ 14 - 5
packages/fcl-registry/src/xregreg.inc

@@ -21,7 +21,8 @@ end;
 Procedure TRegistry.SysRegFree;
 
 begin
-  TXMLRegistry(FSysData).Flush;
+  if Assigned(FSysData) then
+    TXMLRegistry(FSysData).Flush;
   TXMLRegistry(FSysData).Free;
 end;
 
@@ -237,13 +238,21 @@ end;
 procedure TRegistry.CloseKey;
 
 begin
-  TXMLRegistry(FSysData).Flush;
-  TXMLRegistry(FSysData).SetRootKey(TXMLRegistry(FSysData).RootKey);
+  // CloseKey is called from destructor, which includes cases of failed construction.
+  // FSysData may be unassigned at this point.
+  if Assigned(FSysData) then
+  begin
+    TXMLRegistry(FSysData).Flush;
+    TXMLRegistry(FSysData).SetRootKey(TXMLRegistry(FSysData).RootKey);
+  end;
 end;
 
 procedure TRegistry.CloseKey(key:HKEY);
 
 begin
-  TXMLRegistry(FSysData).Flush;
-  TXMLRegistry(FSysData).SetRootKey(TXMLRegistry(FSysData).RootKey);
+  if Assigned(FSysData) then
+  begin
+    TXMLRegistry(FSysData).Flush;
+    TXMLRegistry(FSysData).SetRootKey(TXMLRegistry(FSysData).RootKey);
+  end;
 end;