View Issue Details

IDProjectCategoryView StatusLast Update
0017970LazarusIDEpublic2010-12-18 15:11
ReporterMaxim GanetskyAssigned ToJuha Manninen 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformWin32OSWindowsOS VersionXP SP2
Product Version0.9.29 (SVN)Product BuildLazarus 0.9.29 r28299 FPC 2.4.3  
Target Version0.9.30Fixed in Version0.9.29 (SVN) 
Summary0017970: laz_xmlcf does not set Modified flag, if deleting node (last child) Can't set an option back to default value in Options dialog
DescriptionWhile working with Editor Colors options dialog I noticed that sometimes if I change some option back to default value it does not get saved.

Steps to reproduce:

1. Take my editoroptions.xml, place it to Lazarus settings directory and open Lazarus. Note that this file contains <ahaWordGroup FrameStyle="slsDashed"/> line.

2. Go to IDE Options->Editor/Display/Colors tab.

3. Select Word-Brackets in its treeview and change its line style from dashed to normal.

4. Press OK.

SynEdit highlights will be correctly updated, but aforementioned line will not be removed from the file, while it should be (because "normal" is default line style). Of course after restarting the IDE highlights will be dashed again.
TagsNo tags attached.
Fixed in Revision28744
LazTarget0.9.30
Widgetset
Attached Files
  • editoroptions.xml (507 bytes)
  • 0001-xmlcfg-Set-Modified-flag-correctly-when-deleting-a-p.patch (969 bytes)
    From 8aa7a7c3c00eab0821fcc2ab9aba6615260653fe Mon Sep 17 00:00:00 2001
    From: Juha Manninen <juha@JuhanLinux.(none)>
    Date: Fri, 17 Dec 2010 19:50:18 +0200
    Subject: [PATCH] xmlcfg: Set Modified flag correctly when deleting a path
    
    ---
     components/codetools/laz_xmlcfg.pas |    2 +-
     1 files changed, 1 insertions(+), 1 deletions(-)
    
    diff --git a/components/codetools/laz_xmlcfg.pas b/components/codetools/laz_xmlcfg.pas
    index 762cc83..575e6b4 100644
    --- a/components/codetools/laz_xmlcfg.pas
    +++ b/components/codetools/laz_xmlcfg.pas
    @@ -551,12 +551,12 @@ begin
       if (Node=nil) then exit;
       while (Node.FirstChild=nil) and (Node.ParentNode<>nil)
       and (Node.ParentNode.ParentNode<>nil) do begin
    +    FModified := True;
         if (Node is TDOMElement) and (not TDOMElement(Node).IsEmpty) then break;
         ParentNode:=Node.ParentNode;
         ParentNode.RemoveChild(Node);
         InvalidatePathCache;
         Node:=ParentNode;
    -    FModified := True;
       end;
     end;
     
    -- 
    1.7.2.3
    
    

Activities

2010-11-17 23:55

 

editoroptions.xml (507 bytes)

Martin Friebe

2010-11-25 01:14

manager   ~0043501

The issue is in the xml config.

Inthe example here, the only chnage to the xml is that a node (which is the last child of its parent) is to be deleded.

DeletePath is correctly called for this node.

the issue is in C:\lazarus_latest\components\codetools\laz_xmlcfg.pas
Line 548
procedure TXMLConfig.InternalCleanNode(Node: TDomNode);

This is called by DeletePath.

And this is where normally the Document.FModified is set to true.

But because the node that is passed in (the now empty parent node) has no children, the loop is never entered.

So the document is never marked as modified, and the doc simple skips saving later.

2010-12-17 18:52

 

0001-xmlcfg-Set-Modified-flag-correctly-when-deleting-a-p.patch (969 bytes)
From 8aa7a7c3c00eab0821fcc2ab9aba6615260653fe Mon Sep 17 00:00:00 2001
From: Juha Manninen <juha@JuhanLinux.(none)>
Date: Fri, 17 Dec 2010 19:50:18 +0200
Subject: [PATCH] xmlcfg: Set Modified flag correctly when deleting a path

---
 components/codetools/laz_xmlcfg.pas |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/components/codetools/laz_xmlcfg.pas b/components/codetools/laz_xmlcfg.pas
index 762cc83..575e6b4 100644
--- a/components/codetools/laz_xmlcfg.pas
+++ b/components/codetools/laz_xmlcfg.pas
@@ -551,12 +551,12 @@ begin
   if (Node=nil) then exit;
   while (Node.FirstChild=nil) and (Node.ParentNode<>nil)
   and (Node.ParentNode.ParentNode<>nil) do begin
+    FModified := True;
     if (Node is TDOMElement) and (not TDOMElement(Node).IsEmpty) then break;
     ParentNode:=Node.ParentNode;
     ParentNode.RemoveChild(Node);
     InvalidatePathCache;
     Node:=ParentNode;
-    FModified := True;
   end;
 end;
 
-- 
1.7.2.3

Juha Manninen

2010-12-17 18:57

developer   ~0044301

The problem was in TXMLConfig.InternalCleanNode as Martin noted. However the reason was little different. The parent node had an attribute, the procedure was quitted too early and Modified flag was not set.
Like:
  <Color Version="6"/>

Patch uploaded, only one line had to moved little up. Someone please apply.

Mattias Gaertner

2010-12-17 20:13

manager   ~0044306

Patch is not correct. It sets Modified even if nothing will change.
DeletePath should set Modified.

Maxim Ganetsky

2010-12-18 15:11

developer   ~0044333

Works ok, thanks.

Issue History

Date Modified Username Field Change
2010-11-17 23:55 Maxim Ganetsky New Issue
2010-11-17 23:55 Maxim Ganetsky File Added: editoroptions.xml
2010-11-17 23:55 Maxim Ganetsky LazTarget => -
2010-11-18 12:09 Vincent Snijders LazTarget - => 0.9.30
2010-11-18 12:09 Vincent Snijders Status new => acknowledged
2010-11-18 12:09 Vincent Snijders Target Version => 0.9.30
2010-11-24 23:56 Martin Friebe Status acknowledged => assigned
2010-11-24 23:56 Martin Friebe Assigned To => Martin Friebe
2010-11-25 01:14 Martin Friebe Note Added: 0043501
2010-11-25 01:14 Martin Friebe Assigned To Martin Friebe =>
2010-11-25 01:15 Martin Friebe Status assigned => confirmed
2010-12-12 22:15 Martin Friebe Summary Can't set an option back to default value in Options dialog => laz_xmlcf does not set Modified flag, if deleting node (last child) Can't set an option back to default value in Options dialog
2010-12-17 18:46 Juha Manninen Status confirmed => assigned
2010-12-17 18:46 Juha Manninen Assigned To => Juha Manninen
2010-12-17 18:52 Juha Manninen File Added: 0001-xmlcfg-Set-Modified-flag-correctly-when-deleting-a-p.patch
2010-12-17 18:57 Juha Manninen Note Added: 0044301
2010-12-17 20:13 Mattias Gaertner Fixed in Revision => 28744
2010-12-17 20:13 Mattias Gaertner Note Added: 0044306
2010-12-17 20:13 Mattias Gaertner Status assigned => resolved
2010-12-17 20:13 Mattias Gaertner Resolution open => fixed
2010-12-18 15:11 Maxim Ganetsky Status resolved => closed
2010-12-18 15:11 Maxim Ganetsky Note Added: 0044333
2010-12-18 15:11 Maxim Ganetsky Fixed in Version => 0.9.29 (SVN)