summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2017-07-07 21:00:17 +0000
committerMatthias Melcher <fltk@matthiasm.com>2017-07-07 21:00:17 +0000
commita8f4fbc2ef6bbe56215f1f1305a16194c268f225 (patch)
treeeeb5224943eef81360c1fbc65c0af58c7897eb3c /src
parent7542e8cb168efcdcfaa9190b9858c75055999bc1 (diff)
STR #2823.2/2: Improved Fl_Preferences "dirty" flag handling.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12305 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Preferences.cxx25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx
index f7f2834ec..9cce411eb 100644
--- a/src/Fl_Preferences.cxx
+++ b/src/Fl_Preferences.cxx
@@ -889,18 +889,19 @@ int Fl_Preferences::RootNode::read() {
} else if ( buf[0]=='+' ) { // value of previous name/value pair spans multiple lines
size_t end = strcspn( buf+1, "\n\r" );
if ( end != 0 ) { // if entry is not empty
- buf[ end+1 ] = 0;
- nd->add( buf+1 );
+ buf[ end+1 ] = 0;
+ nd->add( buf+1 );
}
} else { // read a name/value pair
size_t end = strcspn( buf, "\n\r" );
if ( end != 0 ) { // if entry is not empty
- buf[ end ] = 0;
- nd->set( buf );
+ buf[ end ] = 0;
+ nd->set( buf );
}
}
}
fclose( f );
+ prefs_->node->clearDirtyFlags();
return 0;
}
@@ -1051,6 +1052,16 @@ char Fl_Preferences::Node::dirty() {
return 0;
}
+// recursively clear all dirty flags
+void Fl_Preferences::Node::clearDirtyFlags() {
+ Fl_Preferences::Node *nd = this;
+ while (nd) {
+ nd->dirty_ = 0;
+ if ( nd->child_ ) nd->child_->clearDirtyFlags();
+ nd = nd->next_;
+ }
+}
+
// write this node (recursively from the last neighbor back to this)
// write all entries
// write all children
@@ -1111,7 +1122,6 @@ Fl_Preferences::Node *Fl_Preferences::Node::addChild( const char *path ) {
char *name = strdup( nameBuffer );
Node *nd = find( name );
free( name );
- dirty_ = 1;
updateIndex();
return nd;
}
@@ -1213,8 +1223,8 @@ Fl_Preferences::Node *Fl_Preferences::Node::find( const char *path ) {
if ( path[ len ] == '/' ) {
Node *nd;
for ( nd = child_; nd; nd = nd->next_ ) {
- Node *nn = nd->find( path );
- if ( nn ) return nn;
+ Node *nn = nd->find( path );
+ if ( nn ) return nn;
}
const char *s = path+len+1;
const char *e = strchr( s, '/' );
@@ -1222,6 +1232,7 @@ Fl_Preferences::Node *Fl_Preferences::Node::find( const char *path ) {
else strlcpy( nameBuffer, s, sizeof(nameBuffer));
nd = new Node( nameBuffer );
nd->setParent( this );
+ dirty_ = 1;
return nd->find( path );
}
}