On Mon, 5 Oct 2009, Lee Jenkins wrote:

Sergei Gorelkin wrote:
Lee Jenkins wrote:


Definitely related to TXMLDocument. Apparently, it is either a complete mess and fraught with memory leaks or am misunderstanding how to use it. Although, its not the first XML API I've used.

Once again, its back to Delphi I go :-(

Your trouble looks like issue 13605, which was fixed in the meantime.
One way out is to update the FPC; if that's not possible, you might want to change your code to look like this:


  lRegItem := lRegs.FirstChild;
  while Assigned(lRegItem) do
    begin
      if lRegItem.nodeType = ELEMENT_NODE then
      begin
{1}     lClassName := TDOMElement(lRegItem).GetAttribute('classname');
        lDataTable := ...
        lObjType := ...
lObjReg := gMapppings.RegisterMapping(lClassName, lDataTable, lObjType);
        with lObjReg do
        begin
          lNode := lRegItem.FirstChild;
          while Assigned(lNode) do
            begin
              if lNode.nodeType = ELEMENT_NODE tnen
              begin
                lpK := ...
                lPropName := ...
                lColName := ...
                lValType := ...

//dtInteger, dtFloat, dtString, dtDateTime, dtBookean, dtBinary)
                lObjReg.RegisterProperty(lPropName, lColName,
TFlexDataType(Integer(gDataTypeStrToInt(lValType))), lPK);
              end;  // if lNode.nodeType
              lNode := lNode.NextSibling;
            end;  // while
        end;  // with lObjReg
     end;     // if lRegItem.nodeType
     lRegItem := lRegItem.nextSibling;
   end;       // while

Note that the change marked as {1} is not related to the problem, it just shows how to get the attribute value in a more short way.


I'll give it a try. I'm updating my snapshot installation of Lazarus on Windows, though I'm not sure if the fix will be included.

Also, Node.NextSibling doesn't seem to work either as it seems to return the exact same node and results in an endless loop.

I have really a LOT of XML code in lazarus, and I've never encountered this.

Apart from private code, the whole of the FPC reference documentation is
in XML, and is built almost daily. We'd definitely notice a problem of
this magnitude.

Michael.

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to