Browse Source

Fixed stupid crash bug in Fl_Preferences.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6990 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
pull/49/head
Matthias Melcher 16 years ago
parent
commit
bb34489826
  1. 4
      FL/Fl_Preferences.H
  2. 15
      src/Fl_Preferences.cxx

4
FL/Fl_Preferences.H

@ -201,8 +201,8 @@ private:
RootNode *root_; // top_ bit set RootNode *root_; // top_ bit set
}; };
char *path_; char *path_;
char dirty_:1; unsigned char dirty_:1;
char top_:1; unsigned char top_:1;
public: public:
Node( const char *path ); Node( const char *path );
~Node(); ~Node();

15
src/Fl_Preferences.cxx

@ -229,6 +229,9 @@ Fl_Preferences::Fl_Preferences( Fl_Preferences *parent, const char *group )
If the given index is invalid (negative or too high), a new group is created If the given index is invalid (negative or too high), a new group is created
with a UUID as a name. with a UUID as a name.
The index needs to be fixed. It is currently backward. Index 0 points
to the last member in the 'list' of preferences.
\param[in] parent reference object for the new group \param[in] parent reference object for the new group
\param[in] groupIndex zero based index into child groups \param[in] groupIndex zero based index into child groups
*/ */
@ -1297,7 +1300,7 @@ Fl_Preferences::RootNode *Fl_Preferences::Node::findRoot()
do { do {
if (n->top_) if (n->top_)
return n->root_; return n->root_;
n = n->parent_; n = n->parent();
} while (n); } while (n);
return 0L; return 0L;
@ -1465,7 +1468,7 @@ Fl_Preferences::Node *Fl_Preferences::Node::search( const char *path, int offset
else if ( path[1] == '/' ) else if ( path[1] == '/' )
{ {
Node *nn = this; Node *nn = this;
while ( nn->parent_ ) nn = nn->parent_; while ( nn->parent() ) nn = nn->parent();
if ( path[2]==0 ) if ( path[2]==0 )
{ // user is searching for root ( "./" ) { // user is searching for root ( "./" )
return nn; return nn;
@ -1543,9 +1546,9 @@ Fl_Preferences::Node *Fl_Preferences::Node::childNode( int ix )
char Fl_Preferences::Node::remove() char Fl_Preferences::Node::remove()
{ {
Node *nd = 0, *np; Node *nd = 0, *np;
if ( parent_ ) if ( parent() )
{ {
nd = parent_->child_; np = 0L; nd = parent()->child_; np = 0L;
for ( ; nd; np = nd, nd = nd->next_ ) for ( ; nd; np = nd, nd = nd->next_ )
{ {
if ( nd == this ) if ( nd == this )
@ -1553,11 +1556,11 @@ char Fl_Preferences::Node::remove()
if ( np ) if ( np )
np->next_ = nd->next_; np->next_ = nd->next_;
else else
parent_->child_ = nd->next_; parent()->child_ = nd->next_;
break; break;
} }
} }
parent_->dirty_ = 1; parent()->dirty_ = 1;
} }
delete this; delete this;
return ( nd != 0 ); return ( nd != 0 );

Loading…
Cancel
Save