Browse Source

* Patch from Bart Broersma to fix deleting non-empty key (bug ID 0035132)

git-svn-id: trunk@41816 -
michael 6 years ago
parent
commit
6c7da3cca4
1 changed files with 11 additions and 1 deletions
  1. 11 1
      packages/fcl-registry/src/xmlreg.pp

+ 11 - 1
packages/fcl-registry/src/xmlreg.pp

@@ -234,13 +234,23 @@ end;
 Function TXmlRegistry.DeleteKey(KeyPath : UnicodeString) : Boolean;
 
 Var
-  N : TDomElement;
+  N, Curr : TDomElement;
+  Node: TDOMNode;
 
 begin
  N:=FindKey(KeyPath);
  Result:=(N<>Nil);
  If Result then
    begin
+   //if a key has subkeys, result shall be false and nothing shall be deleted
+   Curr:=N;
+   Node:=Curr.FirstChild;
+   While Assigned(Node) do
+     begin
+     If (Node.NodeType=ELEMENT_NODE) and (Node.NodeName=SKey) then
+       Exit(False);
+     Node:=Node.NextSibling;
+     end;
    (N.ParentNode as TDomElement).RemoveChild(N);
    FDirty:=True;
    MaybeFlush;