[lazarus] Compiler Options
Peter Dyson
peter at skel.demon.co.uk
Wed May 3 07:11:21 EDT 2000
Ok I worked out what is happening here.
The first pass through you create an element node and therefore the
AppendChild works fine as TDOMNode_WithChildren.AppendChild method
gets called. The second time you call it the element exists, but you
force the element to be a node object not an element object. When the
append child is called when replacing the old child, it works remove
node then append node, then TDOMNode.AppendChild
is called which is a virtual method.
The solution is define subnode as element not node.
----- Original Message -----
From: Curtis White <cwhite at aracnet.com>
To: <lazarus at miraclec.com>
Sent: Wednesday, May 03, 2000 5:18 AM
Subject: [lazarus] Compiler Options
> I just committed a fixed version of the compileroptions.pp file with
all
> the C style += replaced with the Pascal version. So the -Sc compiler
flag
> shouldn't be necessary any more.
>
> At the same time, I found a problem. When you open the Compiler
Options
> dialog and press the Apply (or OK) button, everything works just
fine the
> first time. If you press either of those buttons a second time, it
crashes
> Lazarus. I am not absolutely certain, but it appears to be a
problem with
> the xmlcfg.pp or dom.pp unit in the fcl/xml directory. Here is what
I have
> traced down so far.
>
> In the compileroptions.pp file, there is a procedure called
> TCompilerOptions.SaveCompilerOptions. This procedure is called any
time the
> Apply or OK buttons are pressed. I commented out all the lines in
this
> function except just the first SetValue call. It is as follows:
>
> xmlcfg.SetValue('CompilerOptions/Parsing/Style/Value', Style);
>
> Style is an Integer. I added a couple of writeln statements to the
bottom
> of the SetValue method in the xmlcfg.pp file. Here is what the
modified
> function looks like:
>
> procedure TXMLConfig.SetValue(const APath, AValue: String);
> var
> node, subnode, attr: TDOMNode;
> i: Integer;
> name, path: String;
> begin
> node := doc.DocumentElement;
> path := APath;
> while True do begin
> i := Pos('/', path);
> if i = 0 then break;
> name := Copy(path, 1, i - 1);
> path := Copy(path, i + 1, Length(path));
> subnode := node.FindNode(name);
> if not Assigned(subnode) then begin
> subnode := doc.CreateElement(name);
> node.AppendChild(subnode);
> end;
> node := subnode;
> end;
> attr := node.Attributes.GetNamedItem(path);
> if not Assigned(attr) then begin
> attr := doc.CreateAttribute(path);
> node.Attributes.SetNamedItem(attr);
> end;
> writeln('++++++++++++++++++++++++ attr.NodeValue := AValue = ' +
AValue);
> attr.NodeValue := AValue;
> writeln('++++++++++++++++++++++++ attr.NodeValue := AValue
finished.');
> end;
>
> So the final writeln should be executed every time the Apply or OK
button
> is pressed. The first time, it is, but the second time it isn't and
it
> crashes on "attr.NodeValue := AValue;". Here are the results that
were
> written out:
>
> 1st Apply:
>
> [TControl.GetText] TEDIT got: "./ppc386.cfg"
> [TControl.GetText] TEDIT got:
>
"/opt/fpc/rtl/i386;/opt/fpc/rtl/inc;/opt/fpc/rtl/linux;/opt/fpc/rtl/ob
jpas;/opt/fpc/fcl/inc;/opt/fpc/fcl/linux;/opt/fpc/lazarus/lcl"
>
> [TControl.GetText] TEDIT got:
> "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66"
> [TControl.GetText] TEDIT got:
>
"/opt/fpc/rtl/linux;/opt/fpc/rtl;/opt/fpc/rtl/objpas;/opt/fpc/fcl/linu
x;/opt/fpc/gtk"
>
> [TControl.GetText] TEDIT got: "/opt/fpc/ppc386"
> ++++++++++++++++++++++++ attr.NodeValue := AValue = 1
> ++++++++++++++++++++++++ attr.NodeValue := AValue finished.
>
>
> 2nd Apply:
>
> [TControl.GetText] TEDIT got: "./ppc386.cfg"
> [TControl.GetText] TEDIT got:
>
"/opt/fpc/rtl/i386;/opt/fpc/rtl/inc;/opt/fpc/rtl/linux;/opt/fpc/rtl/ob
jpas;/opt/fpc/fcl/inc;/opt/fpc/fcl/linux;/opt/fpc/lazarus/lcl"
>
> [TControl.GetText] TEDIT got:
> "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66"
> [TControl.GetText] TEDIT got:
>
"/opt/fpc/rtl/linux;/opt/fpc/rtl;/opt/fpc/rtl/objpas;/opt/fpc/fcl/linu
x;/opt/fpc/gtk"
>
> [TControl.GetText] TEDIT got: "/opt/fpc/ppc386"
> ++++++++++++++++++++++++ attr.NodeValue := AValue = 1
> An unhandled exception occurred at 0x08074299 :
> EDOMHIERARCHYREQUEST in NodeWC.InsertBefore
> 0x08074299
> 0x00000000
>
> It is interesting because the value is the same both times, but it
is
> crashing the second time for some reason.
>
> Can someone take a look at this and see if you can find out what is
> happening?
>
>
> Curtis
>
>
> _________________________________________________________________
> To unsubscribe: mail lazarus-request at miraclec.com with
> "unsubscribe" as the Subject
> archives at http://www.miraclec.com/list_archives/lazarus
>
More information about the Lazarus
mailing list