View Issue Details

IDProjectCategoryView StatusLast Update
0006062JEDI Code LibraryJclSimpleXmlpublic2019-08-14 14:04
ReporterwestphalAssigned Tojfudickar 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionVersion 2.5 (Subversion repository/Daily zips) 
Target VersionFixed in Version 
Summary0006062: TJclSimpleXMLElems.delete leave ghost item
Descriptionusing Node.Items.ItemNamed['item1'] to create an element (with option sxoAutoCreate) return wrong element if it was deleted before.

see exemple in additional Information
Additional Informationvar
  xml : TJclSimpleXML;
  pa,Node : TJclSimpleXMLElem;
begin
  xml := TJclSimpleXML.Create;
  try
    pa := xml.Root;
    pa.Name := 'conf';
    Xml.Options := Xml.Options + [sxoAutoCreate];

    node := pa.Items.Add('item1');
    pa.Items.Add('item2');

    //pa.items.Notify(node, opRemove);
    pa.items.Delete('item1');
    node := xml.Root;
    Node.Items.ItemNamed['item1'];

    memo1.text := xml.SaveToString;
    memo1.lines.Add('pa.Items.ItemNamed[''item2''].Name = '+ pa.Items.ItemNamed['item2'].Name +' ???' );

  finally
    xml.Free;
  end;
end;
TagsNo tags attached.
Fixed in revision
IDE versionAll

Activities

westphal

2013-01-15 12:17

reporter   ~0020331

This is a problem when using 2 MRU components and a appXMLstorage, as they use this way to update the xml file.

westphal

2013-01-15 13:47

reporter   ~0020333

in the exemple,
a/ item1 as index 0 and item2 as index 1
b/ item1 is deleted, then item2 as index 0
c/ item1 is re-created then now item 1 as index 1

the FElems: TJclSimpleItemHashedList; is updated for item1 (FNameHash.Remove) but not for the new index of item2 !

a working correction would be:

procedure TJclSimpleItemHashedList.Notify(Ptr: Pointer; Action: TListNotification);
begin
  if (Action = lnDeleted) and (FNameHash <> nil) then
  begin
    InvalidateHash;
    {
    if FCaseSensitive then
      FNameHash.Remove(TJclSimpleItem(Ptr).Name)
    else
      FNameHash.Remove(UpperCase(TJclSimpleItem(Ptr).Name));
      }
  end;
  inherited Notify(Ptr, Action);
end;

jfudickar

2013-06-16 23:03

developer   ~0020532

Commited to github

mh

2019-08-13 19:06

reporter   ~0021876

Ok, it has been commited to Github according to jfudickar (which I believe), but why is this issue then still on "feedback" status? Has the fix been merged in, is there any issue with the fix...? Or should this one be "resolved"?

jfudickar

2019-08-14 14:03

developer   ~0021878

My fault :-(

Issue History

Date Modified Username Field Change
2013-01-15 12:16 westphal New Issue
2013-01-15 12:16 westphal IDE version => All
2013-01-15 12:17 westphal Note Added: 0020331
2013-01-15 13:47 westphal Note Added: 0020333
2013-06-16 23:03 jfudickar Note Added: 0020532
2013-06-16 23:03 jfudickar Assigned To => jfudickar
2013-06-16 23:03 jfudickar Status new => feedback
2019-08-13 19:06 mh Note Added: 0021876
2019-08-14 14:03 jfudickar Note Added: 0021878
2019-08-14 14:04 jfudickar Status feedback => resolved
2019-08-14 14:04 jfudickar Resolution open => fixed